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

package parser

import "github.com/cockroachdb/cockroach/pkg/sql/parser"

Code generated by goyacc. GENERATED FILE DO NOT EDIT

Index

Package Files

aggregate_builtins.go alter_table.go backup.go builtins.go col_types.go constant.go copy.go create.go datum.go decimal.go delete.go drop.go encode.go eval.go explain.go expr.go format.go function_definition.go function_name.go generator_builtins.go grant.go hide_constants.go indexed_vars.go insert.go interval.go keywords.go name_part.go normalize.go overload.go parse.go pg_builtins.go placeholders.go prepare.go regexp_cache.go rename.go reserved_keywords.go returning.go revoke.go scan.go select.go set.go show.go split.go sql.go star_datum.go stmt.go table_name.go table_pattern.go table_ref.go truncate.go txn.go type.go type_check.go union.go update.go values.go var_name.go walk.go window_builtins.go

Constants

const (
    TimestampJdbcFormat = timestampFormat + ".999999 -07:00:00"
    TimestampNodeFormat = timestampFormat + ".999999-07:00"
)

time.Time formats.

const (
    DistinctFuncType funcType
    AllFuncType
)

FuncExpr.Type

const ACTION = 57362
const ADD = 57363
const ALL = 57364
const ALTER = 57365
const ANALYSE = 57366
const ANALYZE = 57367
const AND = 57368
const ANNOTATE_TYPE = 57370
const ANY = 57369
const ARRAY = 57371
const AS = 57372
const ASC = 57373
const ASYMMETRIC = 57374
const AS_LA = 57651
const AT = 57375
const BACKUP = 57376
const BCONST = 57348
const BEGIN = 57377
const BETWEEN = 57378
const BIGINT = 57379
const BIGSERIAL = 57380
const BIT = 57381
const BLOB = 57382
const BOOL = 57383
const BOOLEAN = 57384
const BOTH = 57385
const BY = 57386
const BYTEA = 57387
const BYTES = 57388
const CASCADE = 57389
const CASE = 57390
const CAST = 57391
const CHAR = 57392
const CHARACTER = 57393
const CHARACTERISTICS = 57394
const CHECK = 57395
const CLUSTER = 57396
const COALESCE = 57397
const COLLATE = 57398
const COLLATION = 57399
const COLUMN = 57400
const COLUMNS = 57401
const COMMIT = 57402
const COMMITTED = 57403
const CONCAT = 57404
const CONFLICT = 57405
const CONSTRAINT = 57406
const CONSTRAINTS = 57407
const COPY = 57408
const COVERING = 57409
const CREATE = 57410
const CROSS = 57411
const CUBE = 57412
const CURRENT = 57413
const CURRENT_CATALOG = 57414
const CURRENT_DATE = 57415
const CURRENT_ROLE = 57416
const CURRENT_TIME = 57417
const CURRENT_TIMESTAMP = 57418
const CURRENT_USER = 57419
const CYCLE = 57420
const DATA = 57421
const DATABASE = 57422
const DATABASES = 57423
const DATE = 57424
const DAY = 57425
const DEALLOCATE = 57429
const DEC = 57426
const DECIMAL = 57427
const DEFAULT = 57428
const DEFERRABLE = 57430
const DELETE = 57431
const DESC = 57432
const DISTINCT = 57433
const DO = 57434
const DOT_DOT = 57354
const DOUBLE = 57435
const DROP = 57436
const ELSE = 57437
const ENCODING = 57438
const END = 57439
const ERROR = 57361
const ESCAPE = 57440
const EXCEPT = 57441
const EXECUTE = 57443
const EXISTS = 57442
const EXPLAIN = 57444
const EXTRACT = 57445
const EXTRACT_DURATION = 57446
const FALSE = 57447
const FAMILY = 57448
const FCONST = 57350
const FETCH = 57449
const FILTER = 57450
const FIRST = 57451
const FLOAT = 57452
const FLOORDIV = 57453
const FOLLOWING = 57454
const FOR = 57455
const FORCE_INDEX = 57456
const FOREIGN = 57457
const FROM = 57458
const FULL = 57459
const GRANT = 57460
const GRANTS = 57461
const GREATER_EQUALS = 57356
const GREATEST = 57462
const GROUP = 57463
const GROUPING = 57464
const HAVING = 57465
const HELP = 57466
const HIGH = 57467
const HOUR = 57468
const ICONST = 57349
const IDENT = 57346
const IF = 57470
const IFNULL = 57471
const ILIKE = 57472
const IN = 57473
const INCREMENTAL = 57469
const INDEX = 57475
const INDEXES = 57476
const INITIALLY = 57477
const INNER = 57478
const INSERT = 57479
const INT = 57480
const INT2VECTOR = 57481
const INT64 = 57483
const INT8 = 57482
const INTEGER = 57484
const INTERLEAVE = 57474
const INTERSECT = 57485
const INTERVAL = 57486
const INTO = 57487
const IS = 57488
const ISOLATION = 57489
const InvalidColIdx = -1

InvalidColIdx is the index value of a non-initialized IndexedVar.

const JOIN = 57490
const KEY = 57491
const KEYS = 57492
const LATERAL = 57493
const LC_COLLATE = 57495
const LC_CTYPE = 57494
const LEADING = 57496
const LEAST = 57497
const LEFT = 57498
const LESS_EQUALS = 57355
const LEVEL = 57499
const LIKE = 57500
const LIMIT = 57501
const LOCAL = 57502
const LOCALTIME = 57503
const LOCALTIMESTAMP = 57504
const LOW = 57505
const LSHIFT = 57506
const MATCH = 57507
const MINUTE = 57508
const MONTH = 57509
const MaxInt = int(MaxUint >> 1)

MaxInt is the maximum value of an int.

const MaxUint = ^uint(0)

MaxUint is the maximum value of an uint.

const NAME = 57511
const NAMES = 57512
const NAN = 57510
const NATURAL = 57513
const NEXT = 57514
const NO = 57515
const NORMAL = 57517
const NOT = 57518
const NOTHING = 57519
const NOT_EQUALS = 57357
const NOT_LA = 57649
const NOT_REGIMATCH = 57360
const NOT_REGMATCH = 57358
const NO_INDEX_JOIN = 57516
const NULL = 57520
const NULLIF = 57521
const NULLS = 57522
const NUMERIC = 57523
const OF = 57524
const OFF = 57525
const OFFSET = 57526
const OID = 57527
const ON = 57528
const ONLY = 57529
const OPTIONS = 57530
const OR = 57531
const ORDER = 57532
const ORDINALITY = 57533
const OUT = 57534
const OUTER = 57535
const OVER = 57536
const OVERLAPS = 57537
const OVERLAY = 57538
const PARENT = 57539
const PARTIAL = 57540
const PARTITION = 57541
const PASSWORD = 57542
const PLACEHOLDER = 57351
const PLACING = 57543
const POSITION = 57544
const POSTFIXOP = 57652
const PRECEDING = 57545
const PRECISION = 57546
const PREPARE = 57547
const PRIMARY = 57548
const PRIORITY = 57549
const RANGE = 57550
const READ = 57551
const REAL = 57552
const RECURSIVE = 57553
const REF = 57554
const REFERENCES = 57555
const REGCLASS = 57556
const REGIMATCH = 57359
const REGNAMESPACE = 57559
const REGPROC = 57557
const REGPROCEDURE = 57558
const REGTYPE = 57560
const RELEASE = 57563
const RENAME = 57561
const REPEATABLE = 57562
const RESET = 57564
const RESTORE = 57565
const RESTRICT = 57566
const RETURNING = 57567
const REVOKE = 57568
const RIGHT = 57569
const ROLLBACK = 57570
const ROLLUP = 57571
const ROW = 57572
const ROWS = 57573
const RSHIFT = 57574
const RestartSavepointName string = "COCKROACH_RESTART"

RestartSavepointName is the only savepoint name that we accept, modulo capitalization.

const SAVEPOINT = 57575
const SCATTER = 57576
const SCONST = 57347
const SEARCH = 57577
const SECOND = 57578
const SELECT = 57579
const SERIAL = 57580
const SERIALIZABLE = 57581
const SESSION = 57582
const SESSION_USER = 57583
const SET = 57584
const SETTING = 57585
const SETTINGS = 57586
const SHOW = 57587
const SIMILAR = 57588
const SIMPLE = 57589
const SMALLINT = 57590
const SMALLSERIAL = 57591
const SNAPSHOT = 57592
const SOME = 57593
const SPLIT = 57594
const SQL = 57595
const START = 57596
const STATUS = 57597
const STDIN = 57598
const STORING = 57601
const STRICT = 57599
const STRING = 57600
const SUBSTRING = 57602
const SYMMETRIC = 57603
const SYSTEM = 57604
const TABLE = 57605
const TABLES = 57606
const TEMPLATE = 57607
const TESTING_RANGES = 57608
const TESTING_RELOCATE = 57609
const TEXT = 57610
const THEN = 57611
const TIME = 57612
const TIMESTAMP = 57613
const TIMESTAMPTZ = 57614
const TO = 57615
const TRAILING = 57616
const TRANSACTION = 57617
const TREAT = 57618
const TRIM = 57619
const TRUE = 57620
const TRUNCATE = 57621
const TYPE = 57622
const TYPEANNOTATE = 57353
const TYPECAST = 57352
const UMINUS = 57653
const UNBOUNDED = 57623
const UNCOMMITTED = 57624
const UNION = 57625
const UNIQUE = 57626
const UNKNOWN = 57627
const UPDATE = 57628
const UPSERT = 57629
const USER = 57630
const USERS = 57631
const USING = 57632
const VALID = 57633
const VALIDATE = 57634
const VALUE = 57635
const VALUES = 57636
const VARCHAR = 57637
const VARIADIC = 57638
const VARYING = 57640
const VIEW = 57639
const WHEN = 57641
const WHERE = 57642
const WINDOW = 57643
const WITH = 57644
const WITHIN = 57645
const WITHOUT = 57646
const WITH_LA = 57650
const YEAR = 57647
const ZONE = 57648

Variables

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)
)
var (
    // DecimalCtx is the default context for decimal operations. Any change
    // in the exponent limits must still guarantee a safe conversion to the
    // postegrs 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,
    }
    // ExactCtx is a decimal context with exact precision.
    ExactCtx = DecimalCtx.WithPrecision(0)
    // HighPrecisionCtx is a decimal context with high precision.
    HighPrecisionCtx = DecimalCtx.WithPrecision(2000)
)
var (
    // TypeNull is the type of a DNull. Can be compared with ==.
    TypeNull Type = tNull{}
    // TypeBool is the type of a DBool. Can be compared with ==.
    TypeBool Type = tBool{}
    // TypeInt is the type of a DInt. Can be compared with ==.
    TypeInt Type = tInt{}
    // TypeFloat is the type of a DFloat. Can be compared with ==.
    TypeFloat Type = tFloat{}
    // TypeDecimal is the type of a DDecimal. Can be compared with ==.
    TypeDecimal Type = tDecimal{}
    // TypeString is the type of a DString. Can be compared with ==.
    TypeString Type = tString{}
    // TypeCollatedString is the type family of a DString. CANNOT be compared with
    // ==.
    TypeCollatedString Type = TCollatedString{}
    // TypeBytes is the type of a DBytes. Can be compared with ==.
    TypeBytes Type = tBytes{}
    // TypeDate is the type of a DDate. Can be compared with ==.
    TypeDate Type = tDate{}
    // TypeTimestamp is the type of a DTimestamp. Can be compared with ==.
    TypeTimestamp Type = tTimestamp{}
    // TypeTimestampTZ is the type of a DTimestampTZ. Can be compared with ==.
    TypeTimestampTZ Type = tTimestampTZ{}
    // TypeInterval is the type of a DInterval. Can be compared with ==.
    TypeInterval Type = tInterval{}
    // TypeTuple is the type family of a DTuple. CANNOT be compared with ==.
    TypeTuple Type = TTuple(nil)
    // TypeTable is the type family of a DTable. CANNOT be compared with ==.
    TypeTable Type = TTable{}
    // TypePlaceholder is the type family of a placeholder. CANNOT be compared
    // with ==.
    TypePlaceholder Type = TPlaceholder{}
    // TypeStringArray is the type family of a DArray containing strings. Can be
    // compared with ==.
    TypeStringArray Type = TArray{TypeString}
    // TypeIntArray is the type family of a DArray containing ints. Can be
    // compared with ==.
    TypeIntArray Type = TArray{TypeInt}
    // TypeAnyArray is the type of a DArray with a wildcard parameterized type.
    // Can be compared with ==.
    TypeAnyArray Type = TArray{TypeAny}
    // TypeAny can be any type. Can be compared with ==.
    TypeAny Type = tAny{}

    // TypeOid is the type of an OID. Can be compared with ==.
    TypeOid = tOid{oid.T_oid}
    // TypeRegClass is the type of an regclass OID variant. Can be compared with ==.
    TypeRegClass = tOid{oid.T_regclass}
    // TypeRegNamespace is the type of an regnamespace OID variant. Can be compared with ==.
    TypeRegNamespace = tOid{oid.T_regnamespace}
    // TypeRegProc is the type of an regproc OID variant. Can be compared with ==.
    TypeRegProc = tOid{oid.T_regproc}
    // TypeRegProcedure is the type of an regprocedure OID variant. Can be compared with ==.
    TypeRegProcedure = tOid{oid.T_regprocedure}
    // TypeRegType is the type of an regtype OID variant. Can be compared with ==.
    TypeRegType = tOid{oid.T_regtype}

    // TypeName is a type-alias for TypeString with a different OID. Can be
    // compared with ==.
    TypeName = wrapTypeWithOid(TypeString, oid.T_name)
    // TypeIntVector is a type-alias for a TypeIntArray with a different OID. Can
    // be compared with ==.
    TypeIntVector = wrapTypeWithOid(TypeIntArray, oid.T_int2vector)
    // TypeNameArray is the type family of a DArray containing the Name alias type.
    // Can be compared with ==.
    TypeNameArray Type = TArray{TypeName}

    // TypesAnyNonArray contains all non-array types.
    TypesAnyNonArray = []Type{
        TypeBool,
        TypeInt,
        TypeFloat,
        TypeDecimal,
        TypeString,
        TypeBytes,
        TypeDate,
        TypeTimestamp,
        TypeTimestampTZ,
        TypeInterval,
        TypeOid,
    }
)
var AbsentReturningClause = &NoReturningClause{}

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

var Aggregates = map[string][]Builtin{
    "array_agg": {
        makeAggBuiltinWithReturnType(
            TypeAny,
            func(args []TypedExpr) Type {
                if len(args) == 0 {
                    return unknownReturnType
                }
                return TArray{args[0].ResolvedType()}
            },
            newArrayAggregate,
            "Aggregates the selected values into an array.",
        ),
    },

    "avg": {
        makeAggBuiltin(TypeInt, TypeDecimal, newIntAvgAggregate,
            "Calculates the average of the selected values."),
        makeAggBuiltin(TypeFloat, TypeFloat, newFloatAvgAggregate,
            "Calculates the average of the selected values."),
        makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalAvgAggregate,
            "Calculates the average of the selected values."),
    },

    "bool_and": {
        makeAggBuiltin(TypeBool, TypeBool, newBoolAndAggregate,
            "Calculates the boolean value of `AND`ing all selected values."),
    },

    "bool_or": {
        makeAggBuiltin(TypeBool, TypeBool, newBoolOrAggregate,
            "Calculates the boolean value of `OR`ing all selected values."),
    },

    "concat_agg": {

        makeAggBuiltin(TypeString, TypeString, newStringConcatAggregate,
            "Concatenates all selected values."),
        makeAggBuiltin(TypeBytes, TypeBytes, newBytesConcatAggregate,
            "Concatenates all selected values."),
    },

    "count": {
        makeAggBuiltin(TypeAny, TypeInt, newCountAggregate,
            "Calculates the number of selected elements."),
    },

    "max": collectBuiltins(func(t Type) Builtin {
        return makeAggBuiltin(t, t, newMaxAggregate,
            "Identifies the maximum selected value.")
    }, TypesAnyNonArray...),
    "min": collectBuiltins(func(t Type) Builtin {
        return makeAggBuiltin(t, t, newMinAggregate,
            "Identifies the minimum selected value.")
    }, TypesAnyNonArray...),

    "sum_int": {
        makeAggBuiltin(TypeInt, TypeInt, newSmallIntSumAggregate,
            "Calculates the sum of the selected values."),
    },

    "sum": {
        makeAggBuiltin(TypeInt, TypeDecimal, newIntSumAggregate,
            "Calculates the sum of the selected values."),
        makeAggBuiltin(TypeFloat, TypeFloat, newFloatSumAggregate,
            "Calculates the sum of the selected values."),
        makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalSumAggregate,
            "Calculates the sum of the selected values."),
        makeAggBuiltin(TypeInterval, TypeInterval, newIntervalSumAggregate,
            "Calculates the sum of the selected values."),
    },

    "variance": {
        makeAggBuiltin(TypeInt, TypeDecimal, newIntVarianceAggregate,
            "Calculates the variance of the selected values."),
        makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalVarianceAggregate,
            "Calculates the variance of the selected values."),
        makeAggBuiltin(TypeFloat, TypeFloat, newFloatVarianceAggregate,
            "Calculates the variance of the selected values."),
    },

    "stddev": {
        makeAggBuiltin(TypeInt, TypeDecimal, newIntStdDevAggregate,
            "Calculates the standard deviation of the selected values."),
        makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalStdDevAggregate,
            "Calculates the standard deviation of the selected values."),
        makeAggBuiltin(TypeFloat, TypeFloat, newFloatStdDevAggregate,
            "Calculates the standard deviation of the selected values."),
    },
}

Aggregates are a special class of builtin functions that are wrapped at execution in a bucketing layer to combine (aggregate) the result of the function being run over many rows. See `aggregateFuncHolder` in the sql package. In particular they must not be simplified during normalization (and thus must be marked as impure), even when they are given a constant argument (e.g. SUM(1)). This is because aggregate functions must return NULL when they are no rows in the source table, so their evaluation must always be delayed until query execution. Exported for use in documentation.

var BinOps = map[BinaryOperator]binOpOverload{
    Bitand: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) & MustBeDInt(right)), nil
            },
        },
    },

    Bitor: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) | MustBeDInt(right)), nil
            },
        },
    },

    Bitxor: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) ^ MustBeDInt(right)), nil
            },
        },
    },

    Plus: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                a, b := MustBeDInt(left), MustBeDInt(right)
                if b > 0 && a > math.MaxInt64-b {
                    return nil, errIntOutOfRange
                }
                if b < 0 && a < math.MinInt64-b {
                    return nil, errIntOutOfRange
                }
                return NewDInt(a + b), nil
            },
        },
        BinOp{
            LeftType:   TypeFloat,
            RightType:  TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(*left.(*DFloat) + *right.(*DFloat)), nil
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := ExactCtx.Add(&dd.Decimal, l, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetCoefficient(int64(r))
                _, err := ExactCtx.Add(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetCoefficient(int64(l))
                _, err := ExactCtx.Add(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDate,
            RightType:  TypeInt,
            ReturnType: TypeDate,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDDate(*left.(*DDate) + DDate(MustBeDInt(right))), nil
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDate,
            ReturnType: TypeDate,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDDate(DDate(MustBeDInt(left)) + *right.(*DDate)), nil
            },
        },
        BinOp{
            LeftType:   TypeTimestamp,
            RightType:  TypeInterval,
            ReturnType: TypeTimestamp,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(left.(*DTimestamp).Time, right.(*DInterval).Duration), time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeTimestamp,
            ReturnType: TypeTimestamp,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(right.(*DTimestamp).Time, left.(*DInterval).Duration), time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeTimestampTZ,
            RightType:  TypeInterval,
            ReturnType: TypeTimestampTZ,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := duration.Add(left.(*DTimestampTZ).Time, right.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeTimestampTZ,
            ReturnType: TypeTimestampTZ,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := duration.Add(right.(*DTimestampTZ).Time, left.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeInterval,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: left.(*DInterval).Duration.Add(right.(*DInterval).Duration)}, nil
            },
        },
        BinOp{
            LeftType:   TypeDate,
            RightType:  TypeInterval,
            ReturnType: TypeTimestampTZ,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTZ := MakeDTimestampTZFromDate(ctx.GetLocation(), left.(*DDate))
                t := duration.Add(leftTZ.Time, right.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeDate,
            ReturnType: TypeTimestampTZ,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                rightTZ := MakeDTimestampTZFromDate(ctx.GetLocation(), right.(*DDate))
                t := duration.Add(rightTZ.Time, left.(*DInterval).Duration)
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
    },

    Minus: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                a, b := MustBeDInt(left), MustBeDInt(right)
                if b < 0 && a > math.MaxInt64+b {
                    return nil, errIntOutOfRange
                }
                if b > 0 && a < math.MinInt64+b {
                    return nil, errIntOutOfRange
                }
                return NewDInt(a - b), nil
            },
        },
        BinOp{
            LeftType:   TypeFloat,
            RightType:  TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(*left.(*DFloat) - *right.(*DFloat)), nil
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := ExactCtx.Sub(&dd.Decimal, l, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetCoefficient(int64(r))
                _, err := ExactCtx.Sub(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetCoefficient(int64(l))
                _, err := ExactCtx.Sub(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDate,
            RightType:  TypeInt,
            ReturnType: TypeDate,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDDate(*left.(*DDate) - DDate(MustBeDInt(right))), nil
            },
        },
        BinOp{
            LeftType:   TypeDate,
            RightType:  TypeDate,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(DInt(*left.(*DDate) - *right.(*DDate))), nil
            },
        },
        BinOp{
            LeftType:   TypeTimestamp,
            RightType:  TypeTimestamp,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                nanos := left.(*DTimestamp).Sub(right.(*DTimestamp).Time).Nanoseconds()
                return &DInterval{Duration: duration.Duration{Nanos: nanos}}, nil
            },
        },
        BinOp{
            LeftType:   TypeTimestampTZ,
            RightType:  TypeTimestampTZ,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                nanos := left.(*DTimestampTZ).Sub(right.(*DTimestampTZ).Time).Nanoseconds()
                return &DInterval{Duration: duration.Duration{Nanos: nanos}}, nil
            },
        },
        BinOp{
            LeftType:   TypeTimestamp,
            RightType:  TypeTimestampTZ,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                nanos := left.(*DTimestamp).Sub(right.(*DTimestampTZ).Time).Nanoseconds()
                return &DInterval{Duration: duration.Duration{Nanos: nanos}}, nil
            },
        },
        BinOp{
            LeftType:   TypeTimestampTZ,
            RightType:  TypeTimestamp,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                nanos := left.(*DTimestampTZ).Sub(right.(*DTimestamp).Time).Nanoseconds()
                return &DInterval{Duration: duration.Duration{Nanos: nanos}}, nil
            },
        },
        BinOp{
            LeftType:   TypeTimestamp,
            RightType:  TypeInterval,
            ReturnType: TypeTimestamp,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return MakeDTimestamp(duration.Add(left.(*DTimestamp).Time, right.(*DInterval).Duration.Mul(-1)), time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeTimestampTZ,
            RightType:  TypeInterval,
            ReturnType: TypeTimestampTZ,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                t := duration.Add(left.(*DTimestampTZ).Time, right.(*DInterval).Duration.Mul(-1))
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeDate,
            RightType:  TypeInterval,
            ReturnType: TypeTimestampTZ,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                leftTZ := MakeDTimestampTZFromDate(ctx.GetLocation(), left.(*DDate))
                t := duration.Add(leftTZ.Time, right.(*DInterval).Duration.Mul(-1))
                return MakeDTimestampTZ(t, time.Microsecond), nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeInterval,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: left.(*DInterval).Duration.Sub(right.(*DInterval).Duration)}, nil
            },
        },
    },

    Mult: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {

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

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

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

        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetCoefficient(int64(r))
                _, err := ExactCtx.Mul(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetCoefficient(int64(l))
                _, err := ExactCtx.Mul(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInterval,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: right.(*DInterval).Duration.Mul(int64(MustBeDInt(left)))}, nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeInt,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return &DInterval{Duration: left.(*DInterval).Duration.Mul(int64(MustBeDInt(right)))}, nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeFloat,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := float64(*right.(*DFloat))
                return &DInterval{Duration: left.(*DInterval).Duration.MulFloat(r)}, nil
            },
        },
    },

    Div: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                rInt := MustBeDInt(right)
                div := ctx.getTmpDec().SetCoefficient(int64(rInt)).SetExponent(0)
                dd := &DDecimal{}
                dd.SetCoefficient(int64(MustBeDInt(left)))
                _, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, div)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeFloat,
            RightType:  TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(*left.(*DFloat) / *right.(*DFloat)), nil
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := DecimalCtx.Quo(&dd.Decimal, l, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetCoefficient(int64(r))
                _, err := DecimalCtx.Quo(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetCoefficient(int64(l))
                _, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeInt,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rInt := MustBeDInt(right)
                if rInt == 0 {
                    return nil, errDivByZero
                }
                return &DInterval{Duration: left.(*DInterval).Duration.Div(int64(rInt))}, nil
            },
        },
        BinOp{
            LeftType:   TypeInterval,
            RightType:  TypeFloat,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := float64(*right.(*DFloat))
                if r == 0.0 {
                    return nil, errDivByZero
                }
                return &DInterval{Duration: left.(*DInterval).Duration.DivFloat(r)}, nil
            },
        },
    },

    FloorDiv: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                rInt := MustBeDInt(right)
                if rInt == 0 {
                    return nil, errDivByZero
                }
                return NewDInt(MustBeDInt(left) / rInt), nil
            },
        },
        BinOp{
            LeftType:   TypeFloat,
            RightType:  TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := float64(*left.(*DFloat))
                r := float64(*right.(*DFloat))
                return NewDFloat(DFloat(math.Trunc(l / r))), nil
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, l, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            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.SetCoefficient(int64(r))
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                if r.Sign() == 0 {
                    return nil, errDivByZero
                }
                dd := &DDecimal{}
                dd.SetCoefficient(int64(l))
                _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
    },

    Mod: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                r := MustBeDInt(right)
                if r == 0 {
                    return nil, errZeroModulus
                }
                return NewDInt(MustBeDInt(left) % r), nil
            },
        },
        BinOp{
            LeftType:   TypeFloat,
            RightType:  TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDFloat(DFloat(math.Mod(float64(*left.(*DFloat)), float64(*right.(*DFloat))))), nil
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, l, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetCoefficient(int64(r))
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetCoefficient(int64(l))
                _, err := HighPrecisionCtx.Rem(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
    },

    Concat: {
        BinOp{
            LeftType:   TypeString,
            RightType:  TypeString,
            ReturnType: TypeString,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDString(string(MustBeDString(left) + MustBeDString(right))), nil
            },
        },
        BinOp{
            LeftType:   TypeBytes,
            RightType:  TypeBytes,
            ReturnType: TypeBytes,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDBytes(*left.(*DBytes) + *right.(*DBytes)), nil
            },
        },
    },

    LShift: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) << uint(MustBeDInt(right))), nil
            },
        },
    },

    RShift: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                return NewDInt(MustBeDInt(left) >> uint(MustBeDInt(right))), nil
            },
        },
    },

    Pow: {
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeInt,
            ReturnType: TypeInt,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return intPow(MustBeDInt(left), MustBeDInt(right))
            },
        },
        BinOp{
            LeftType:   TypeFloat,
            RightType:  TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                f := math.Pow(float64(*left.(*DFloat)), float64(*right.(*DFloat)))
                return NewDFloat(DFloat(f)), nil
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                _, err := DecimalCtx.Pow(&dd.Decimal, l, r)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeDecimal,
            RightType:  TypeInt,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := &left.(*DDecimal).Decimal
                r := MustBeDInt(right)
                dd := &DDecimal{}
                dd.SetCoefficient(int64(r))
                _, err := DecimalCtx.Pow(&dd.Decimal, l, &dd.Decimal)
                return dd, err
            },
        },
        BinOp{
            LeftType:   TypeInt,
            RightType:  TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
                l := MustBeDInt(left)
                r := &right.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.SetCoefficient(int64(l))
                _, err := DecimalCtx.Pow(&dd.Decimal, &dd.Decimal, r)
                return dd, err
            },
        },
    },
}

BinOps contains the binary operations indexed by operation type.

var Builtins = map[string][]Builtin{

    "length": {
        stringBuiltin1(func(s string) (Datum, error) {
            return NewDInt(DInt(utf8.RuneCountInString(s))), nil
        }, TypeInt, "Calculates the number of characters in `val`."),
        bytesBuiltin1(func(s string) (Datum, error) {
            return NewDInt(DInt(len(s))), nil
        }, TypeInt, "Calculates the number of bytes in `val`."),
    },

    "octet_length": {
        stringBuiltin1(func(s string) (Datum, error) {
            return NewDInt(DInt(len(s))), nil
        }, TypeInt, "Calculates the number of bytes used to represent `val`."),
        bytesBuiltin1(func(s string) (Datum, error) {
            return NewDInt(DInt(len(s))), nil
        }, TypeInt, "Calculates the number of bytes in `val`."),
    },

    "lower": {stringBuiltin1(func(s string) (Datum, error) {
        return NewDString(strings.ToLower(s)), nil
    }, TypeString, "Converts all characters in `val`to their lower-case equivalents.")},

    "upper": {stringBuiltin1(func(s string) (Datum, error) {
        return NewDString(strings.ToUpper(s)), nil
    }, TypeString, "Converts all characters in `val`to their to their upper-case equivalents.")},

    "substr":    substringImpls,
    "substring": substringImpls,

    "concat": {
        Builtin{
            Types:      VariadicType{TypeString},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                var buffer bytes.Buffer
                for _, d := range args {
                    if d == DNull {
                        continue
                    }
                    buffer.WriteString(string(MustBeDString(d)))
                }
                return NewDString(buffer.String()), nil
            },
            Info: "Concatenates a comma-separated list of strings.",
        },
    },

    "concat_ws": {
        Builtin{
            Types:      VariadicType{TypeString},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                if len(args) == 0 {
                    return nil, errInsufficientArgs
                }
                if args[0] == DNull {
                    return DNull, nil
                }
                sep := string(MustBeDString(args[0]))
                var buf bytes.Buffer
                prefix := ""
                for _, d := range args[1:] {
                    if d == DNull {
                        continue
                    }

                    buf.WriteString(prefix)
                    prefix = sep
                    buf.WriteString(string(MustBeDString(d)))
                }
                return NewDString(buf.String()), nil
            },
            Info: "Uses the first argument as a separator between the concatenation of the " +
                "subsequent arguments. <br/><br/>For example `concat_ws('!','wow','great')` " +
                "returns `wow!great`.",
        },
    },

    "to_uuid": {
        Builtin{
            Types:      ArgTypes{{"val", TypeString}},
            ReturnType: fixedReturnType(TypeBytes),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                s := string(MustBeDString(args[0]))
                uv, err := uuid.FromString(s)
                if err != nil {
                    return nil, err
                }
                return NewDBytes(DBytes(uv.GetBytes())), nil
            },
            Info: "Converts the character string representation of a UUID to its byte string " +
                "representation.",
        },
    },

    "from_uuid": {
        Builtin{
            Types:      ArgTypes{{"val", TypeBytes}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                b := []byte(*args[0].(*DBytes))
                uv, err := uuid.FromBytes(b)
                if err != nil {
                    return nil, err
                }
                return NewDString(uv.String()), nil
            },
            Info: "Converts the byte string representation of a UUID to its character string " +
                "representation.",
        },
    },

    "from_ip": {
        Builtin{
            Types:      ArgTypes{{"val", TypeBytes}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                ipstr := args[0].(*DBytes)
                nboip := net.IP(*ipstr)
                sv := nboip.String()

                if sv == "<nil>" {
                    return nil, errZeroIP
                }
                return NewDString(sv), nil
            },
            Info: "Converts the byte string representation of an IP to its character string " +
                "representation.",
        },
    },

    "to_ip": {
        Builtin{
            Types:      ArgTypes{{"val", TypeString}},
            ReturnType: fixedReturnType(TypeBytes),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                ipdstr := MustBeDString(args[0])
                ip := net.ParseIP(string(ipdstr))

                if ip == nil {
                    return nil, fmt.Errorf("invalid IP format: %s", ipdstr.String())
                }
                return NewDBytes(DBytes(ip)), nil
            },
            Info: "Converts the character string representation of an IP to its byte string " +
                "representation.",
        },
    },

    "split_part": {
        Builtin{
            Types: ArgTypes{
                {"input", TypeString},
                {"delimiter", TypeString},
                {"return_index_pos", TypeInt},
            },
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                text := string(MustBeDString(args[0]))
                sep := string(MustBeDString(args[1]))
                field := int(MustBeDInt(args[2]))

                if field <= 0 {
                    return nil, fmt.Errorf("field position %d must be greater than zero", field)
                }

                splits := strings.Split(text, sep)
                if field > len(splits) {
                    return NewDString(""), nil
                }
                return NewDString(splits[field-1]), nil
            },
            Info: "Splits `input` on `delimiter` and return the value in the `return_index_pos`  " +
                "position (starting at 1). <br/><br/>For example, `split_part('123.456.789.0','.',3)`" +
                "returns `789`.",
        },
    },

    "repeat": {
        Builtin{
            Types:      ArgTypes{{"input", TypeString}, {"repeat_counter", TypeInt}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (_ Datum, err error) {
                s := string(MustBeDString(args[0]))
                count := int(MustBeDInt(args[1]))
                if count < 0 {
                    count = 0
                }

                defer func() {
                    if r := recover(); r != nil {
                        err = fmt.Errorf("%s", r)
                    }
                }()
                return NewDString(strings.Repeat(s, count)), nil
            },
            Info: "Concatenates `input` `repeat_counter` number of times.<br/><br/>For example, " +
                "`repeat('dog', 2)` returns `dogdog`.",
        },
    },

    "ascii": {stringBuiltin1(func(s string) (Datum, error) {
        for _, ch := range s {
            return NewDInt(DInt(ch)), nil
        }
        return nil, errEmptyInputString
    }, TypeInt, "Calculates the ASCII value for the first character in `val`.")},

    "md5": {stringBuiltin1(func(s string) (Datum, error) {
        return NewDString(fmt.Sprintf("%x", md5.Sum([]byte(s)))), nil
    }, TypeString, "Calculates the MD5 hash value of `val`.")},

    "sha1": {stringBuiltin1(func(s string) (Datum, error) {
        return NewDString(fmt.Sprintf("%x", sha1.Sum([]byte(s)))), nil
    }, TypeString, "Calculates the SHA1 hash value of `val`.")},

    "sha256": {stringBuiltin1(func(s string) (Datum, error) {
        return NewDString(fmt.Sprintf("%x", sha256.Sum256([]byte(s)))), nil
    }, TypeString, "Calculates the SHA256 hash value of `val`.")},

    "to_hex": {
        Builtin{
            Types:      ArgTypes{{"val", TypeInt}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return NewDString(fmt.Sprintf("%x", int64(MustBeDInt(args[0])))), nil
            },
            Info: "Converts `val` to its hexadecimal representation.",
        },
    },

    "strpos": {stringBuiltin2("input", "find", func(s, substring string) (Datum, error) {
        index := strings.Index(s, substring)
        if index < 0 {
            return DZero, nil
        }

        return NewDInt(DInt(utf8.RuneCountInString(s[:index]) + 1)), nil
    }, TypeInt, "Calculates the position where the string `find` begins in `input`. <br/><br/>For"+
        " example, `strpos('doggie', 'gie')` returns `4`.")},

    "overlay": {
        Builtin{
            Types: ArgTypes{
                {"input", TypeString},
                {"overlay_val", TypeString},
                {"start_pos", TypeInt},
            },
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                s := string(MustBeDString(args[0]))
                to := string(MustBeDString(args[1]))
                pos := int(MustBeDInt(args[2]))
                size := utf8.RuneCountInString(to)
                return overlay(s, to, pos, size)
            },
            Info: "Replaces characters in `input` with `overlay_val` starting at `start_pos` " +
                "(begins at 1). <br/><br/>For example, `overlay('doggie', 'CAT', 2)` returns " +
                "`dCATie`.",
        },
        Builtin{
            Types: ArgTypes{
                {"input", TypeString},
                {"overlay_val", TypeString},
                {"start_pos", TypeInt},
                {"end_pos", TypeInt},
            },
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                s := string(MustBeDString(args[0]))
                to := string(MustBeDString(args[1]))
                pos := int(MustBeDInt(args[2]))
                size := int(MustBeDInt(args[3]))
                return overlay(s, to, pos, size)
            },
            Info: "Deletes the characters in `input` between `start_pos` and `end_pos` (count " +
                "starts at 1), and then insert `overlay_val` at `start_pos`.",
        },
    },

    "btrim": {
        stringBuiltin2("input", "trim_chars", func(s, chars string) (Datum, error) {
            return NewDString(strings.Trim(s, chars)), nil
        }, TypeString, "Removes any characters included in `trim_chars` from the beginning or end"+
            " of `input` (applies recursively). <br/><br/>For example, `btrim('doggie', 'eod')` "+
            "returns `ggi`."),
        stringBuiltin1(func(s string) (Datum, error) {
            return NewDString(strings.TrimSpace(s)), nil
        }, TypeString, "Removes all spaces from the beginning and end of `val`."),
    },

    "ltrim": {
        stringBuiltin2("input", "trim_chars", func(s, chars string) (Datum, error) {
            return NewDString(strings.TrimLeft(s, chars)), nil
        }, TypeString, "Removes any characters included in `trim_chars` from the beginning "+
            "(left-hand side) of `input` (applies recursively). <br/><br/>For example, "+
            "`ltrim('doggie', 'od')` returns `ggie`."),
        stringBuiltin1(func(s string) (Datum, error) {
            return NewDString(strings.TrimLeftFunc(s, unicode.IsSpace)), nil
        }, TypeString, "Removes all spaces from the beginning (left-hand side) of `val`."),
    },

    "rtrim": {
        stringBuiltin2("input", "trim_chars", func(s, chars string) (Datum, error) {
            return NewDString(strings.TrimRight(s, chars)), nil
        }, TypeString, "Removes any characters included in `trim_chars` from the end (right-hand "+
            "side) of `input` (applies recursively). <br/><br/>For example, `rtrim('doggie', 'ei')` "+
            "returns `dogg`."),
        stringBuiltin1(func(s string) (Datum, error) {
            return NewDString(strings.TrimRightFunc(s, unicode.IsSpace)), nil
        }, TypeString, "Removes all spaces from the end (right-hand side) of `val`."),
    },

    "reverse": {stringBuiltin1(func(s string) (Datum, error) {
        runes := []rune(s)
        for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
            runes[i], runes[j] = runes[j], runes[i]
        }
        return NewDString(string(runes)), nil
    }, TypeString, "Reverses the order of the string's characters.")},

    "replace": {stringBuiltin3(
        "input", "find", "replace",
        func(input, from, to string) (Datum, error) {
            return NewDString(strings.Replace(input, from, to, -1)), nil
        },
        TypeString,
        "Replaces all occurrences of `find` with `replace` in `input`",
    )},

    "translate": {stringBuiltin3(
        "input", "find", "replace",
        func(s, from, to string) (Datum, error) {
            const deletionRune = utf8.MaxRune + 1
            translation := make(map[rune]rune, len(from))
            for _, fromRune := range from {
                toRune, size := utf8.DecodeRuneInString(to)
                if toRune == utf8.RuneError {
                    toRune = deletionRune
                } else {
                    to = to[size:]
                }
                translation[fromRune] = toRune
            }

            runes := make([]rune, 0, len(s))
            for _, c := range s {
                if t, ok := translation[c]; ok {
                    if t != deletionRune {
                        runes = append(runes, t)
                    }
                } else {
                    runes = append(runes, c)
                }
            }
            return NewDString(string(runes)), nil
        }, TypeString, "In `input`, replaces the first character from `find` with the first "+
            "character in `replace`; repeat for each character in `find`. <br/><br/>For example, "+
            "`translate('doggie', 'dog', '123');` returns `1233ie`.")},

    "regexp_extract": {
        Builtin{
            Types:      ArgTypes{{"input", TypeString}, {"regex", TypeString}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                s := string(MustBeDString(args[0]))
                pattern := string(MustBeDString(args[1]))
                return regexpExtract(ctx, s, pattern, `\`)
            },
            Info: "Returns the first match for the Regular Expression `regex` in `input`.",
        },
    },

    "regexp_replace": {
        Builtin{
            Types: ArgTypes{
                {"input", TypeString},
                {"regex", TypeString},
                {"replace", TypeString},
            },
            ReturnType: fixedReturnType(TypeString),
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                s := string(MustBeDString(args[0]))
                pattern := string(MustBeDString(args[1]))
                to := string(MustBeDString(args[2]))
                return regexpReplace(ctx, s, pattern, to, "")
            },
            Info: "Replaces matches for the Regular Expression `regex` in `input` with the " +
                "Regular Expression `replace`.",
        },
        Builtin{
            Types: ArgTypes{
                {"input", TypeString},
                {"regex", TypeString},
                {"replace", TypeString},
                {"flags", TypeString},
            },
            ReturnType: fixedReturnType(TypeString),
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                s := string(MustBeDString(args[0]))
                pattern := string(MustBeDString(args[1]))
                to := string(MustBeDString(args[2]))
                sqlFlags := string(MustBeDString(args[3]))
                return regexpReplace(ctx, s, pattern, to, sqlFlags)
            },
            Info: "Replaces matches for the Regular Expression `regex` in `input` with the Regular " +
                "Expression `replace` using `flags`.<br/><br/>CockroachDB supports the following " +
                "flags:<br/><br/>&#8226; **c**: Case-sensitive matching<br/><br/>&#8226; **g**: " +
                "Global matching (match each substring instead of only the first).<br/><br/>&#8226; " +
                "**i**: Case-insensitive matching<br/><br/>&#8226; **m** or **n**: Newline-sensitive " +
                "`.` and negated brackets (`[^...]`) do not match newline characters (preventing " +
                "matching: matches from crossing newlines unless explicitly defined to); `^` and " +
                "`$` match the space before and after newline characters respectively (so characters " +
                "between newline characters are treated as if they're on a separate line).<br/>" +
                "<br/>&#8226; **p**: Partial newline-sensitive matching: `.` and negated brackets " +
                "(`[^...]`) do not match newline characters (preventing matches from crossing " +
                "newlines unless explicitly defined to), but `^` and `$` still only match the " +
                "beginning and end of `val`.<br/><br/>&#8226; **s**: Newline-insensitive " +
                "matching *(default)*.<br/><br/>&#8226; **w**: Inverse partial newline-sensitive " +
                "matching:`.` and negated brackets (`[^...]`) *do* match newline characters, but  `^` " +
                "and `$` match the space before and after newline characters respectively (so " +
                "characters between newline characters are treated as if they're on a separate line).",
        },
    },

    "initcap": {stringBuiltin1(func(s string) (Datum, error) {
        return NewDString(strings.Title(strings.ToLower(s))), nil
    }, TypeString, "Capitalizes the first letter of `val`.")},

    "left": {
        Builtin{
            Types:      ArgTypes{{"input", TypeBytes}, {"return_set", TypeInt}},
            ReturnType: fixedReturnType(TypeBytes),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                bytes := []byte(*args[0].(*DBytes))
                n := int(MustBeDInt(args[1]))

                if n < -len(bytes) {
                    n = 0
                } else if n < 0 {
                    n = len(bytes) + n
                } else if n > len(bytes) {
                    n = len(bytes)
                }
                return NewDBytes(DBytes(bytes[:n])), nil
            },
            Info: "Returns the first `return_set` bytes from `input`.",
        },
        Builtin{
            Types:      ArgTypes{{"input", TypeString}, {"return_set", TypeInt}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                runes := []rune(string(MustBeDString(args[0])))
                n := int(MustBeDInt(args[1]))

                if n < -len(runes) {
                    n = 0
                } else if n < 0 {
                    n = len(runes) + n
                } else if n > len(runes) {
                    n = len(runes)
                }
                return NewDString(string(runes[:n])), nil
            },
            Info: "Returns the first `return_set` characters from `input`.",
        },
    },

    "right": {
        Builtin{
            Types:      ArgTypes{{"input", TypeBytes}, {"return_set", TypeInt}},
            ReturnType: fixedReturnType(TypeBytes),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                bytes := []byte(*args[0].(*DBytes))
                n := int(MustBeDInt(args[1]))

                if n < -len(bytes) {
                    n = 0
                } else if n < 0 {
                    n = len(bytes) + n
                } else if n > len(bytes) {
                    n = len(bytes)
                }
                return NewDBytes(DBytes(bytes[len(bytes)-n:])), nil
            },
            Info: "Returns the last `return_set` bytes from `input`.",
        },
        Builtin{
            Types:      ArgTypes{{"input", TypeString}, {"return_set", TypeInt}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                runes := []rune(string(MustBeDString(args[0])))
                n := int(MustBeDInt(args[1]))

                if n < -len(runes) {
                    n = 0
                } else if n < 0 {
                    n = len(runes) + n
                } else if n > len(runes) {
                    n = len(runes)
                }
                return NewDString(string(runes[len(runes)-n:])), nil
            },
            Info: "Returns the last `return_set` characters from `input`.",
        },
    },

    "random": {
        Builtin{
            Types:                   ArgTypes{},
            ReturnType:              fixedReturnType(TypeFloat),
            impure:                  true,
            needsRepeatedEvaluation: true,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return NewDFloat(DFloat(rand.Float64())), nil
            },
            Info: "Returns a random float between 0 and 1.",
        },
    },

    "unique_rowid": {
        Builtin{
            Types:      ArgTypes{},
            ReturnType: fixedReturnType(TypeInt),
            category:   categoryIDGeneration,
            impure:     true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return NewDInt(GenerateUniqueInt(ctx.NodeID)), nil
            },
            Info: "Returns a unique ID used by CockroachDB to generate unique row IDs if a " +
                "Primary Key isn't defined for the table. The value is a combination of the " +
                " insert timestamp and the ID of the node executing the statement, which " +
                " guarantees this combination is globally unique.",
        },
    },

    "experimental_uuid_v4": {uuidV4Impl},
    "uuid_v4":              {uuidV4Impl},

    "greatest": {
        Builtin{
            Types:      HomogeneousType{},
            ReturnType: identityReturnType(0),
            category:   categoryComparison,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return pickFromTuple(ctx, true, args)
            },
            Info: "Returns the element with the greatest value.",
        },
    },

    "least": {
        Builtin{
            Types:      HomogeneousType{},
            ReturnType: identityReturnType(0),
            category:   categoryComparison,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return pickFromTuple(ctx, false, args)
            },
            Info: "Returns the element with the lowest value.",
        },
    },

    "experimental_strftime": {
        Builtin{
            Types:      ArgTypes{{"input", TypeTimestamp}, {"extract_format", TypeString}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                fromTime := args[0].(*DTimestamp).Time
                format := string(MustBeDString(args[1]))
                t, err := strtime.Strftime(fromTime, format)
                if err != nil {
                    return nil, err
                }
                return NewDString(t), nil
            },
            Info: "From `input`, extracts and formats the time as identified in `extract_format` " +
                "using standard `strftime` notation (though not all formatting is supported).",
        },
        Builtin{
            Types:      ArgTypes{{"input", TypeDate}, {"extract_format", TypeString}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                fromTime := time.Unix(int64(*args[0].(*DDate))*secondsInDay, 0).UTC()
                format := string(MustBeDString(args[1]))
                t, err := strtime.Strftime(fromTime, format)
                if err != nil {
                    return nil, err
                }
                return NewDString(t), nil
            },
            Info: "From `input`, extracts and formats the time as identified in `extract_format` " +
                "using standard `strftime` notation (though not all formatting is supported).",
        },
        Builtin{
            Types:      ArgTypes{{"input", TypeTimestampTZ}, {"extract_format", TypeString}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                fromTime := args[0].(*DTimestampTZ).Time
                format := string(MustBeDString(args[1]))
                t, err := strtime.Strftime(fromTime, format)
                if err != nil {
                    return nil, err
                }
                return NewDString(t), nil
            },
            Info: "From `input`, extracts and formats the time as identified in `extract_format` " +
                "using standard `strftime` notation (though not all formatting is supported).",
        },
    },

    "experimental_strptime": {
        Builtin{
            Types:      ArgTypes{{"input", TypeString}, {"format", TypeString}},
            ReturnType: fixedReturnType(TypeTimestampTZ),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                toParse := string(MustBeDString(args[0]))
                format := string(MustBeDString(args[1]))
                t, err := strtime.Strptime(toParse, format)
                if err != nil {
                    return nil, err
                }
                return MakeDTimestampTZ(t.UTC(), time.Microsecond), nil
            },
            Info: "Returns `input` as a timestamptz using `format` (which uses standard " +
                "`strptime` formatting).",
        },
    },

    "age": {
        Builtin{
            Types:        ArgTypes{{"val", TypeTimestampTZ}},
            ReturnType:   fixedReturnType(TypeInterval),
            ctxDependent: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return timestampMinusBinOp.fn(ctx, ctx.GetTxnTimestamp(time.Microsecond), args[0])
            },
            Info: "Calculates the interval between `val` and the current time.",
        },
        Builtin{
            Types:      ArgTypes{{"begin", TypeTimestampTZ}, {"end", TypeTimestampTZ}},
            ReturnType: fixedReturnType(TypeInterval),
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return timestampMinusBinOp.fn(ctx, args[0], args[1])
            },
            Info: "Calculates the interval between `begin` and `end`.",
        },
    },

    "current_date": {
        Builtin{
            Types:        ArgTypes{},
            ReturnType:   fixedReturnType(TypeDate),
            ctxDependent: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                t := ctx.GetTxnTimestamp(time.Microsecond).Time
                return NewDDateFromTime(t, ctx.GetLocation()), nil
            },
            Info: "Returns the current date.",
        },
    },

    "now":                   txnTSImpl,
    "current_timestamp":     txnTSImpl,
    "transaction_timestamp": txnTSImpl,

    "statement_timestamp": {
        Builtin{
            Types:             ArgTypes{},
            ReturnType:        fixedReturnType(TypeTimestampTZ),
            preferredOverload: true,
            impure:            true,
            ctxDependent:      true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return MakeDTimestampTZ(ctx.GetStmtTimestamp(), time.Microsecond), nil
            },
            Info: "Returns the current statement's timestamp.",
        },
        Builtin{
            Types:        ArgTypes{},
            ReturnType:   fixedReturnType(TypeTimestamp),
            impure:       true,
            ctxDependent: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return MakeDTimestamp(ctx.GetStmtTimestamp(), time.Microsecond), nil
            },
            Info: "Returns the current statement's timestamp.",
        },
    },

    "cluster_logical_timestamp": {
        Builtin{
            Types:        ArgTypes{},
            ReturnType:   fixedReturnType(TypeDecimal),
            category:     categorySystemInfo,
            impure:       true,
            ctxDependent: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                return ctx.GetClusterTimestamp(), nil
            },
            Info: "This function is used only by CockroachDB's developers for testing purposes.",
        },
    },

    "clock_timestamp": {
        Builtin{
            Types:             ArgTypes{},
            ReturnType:        fixedReturnType(TypeTimestampTZ),
            preferredOverload: true,
            impure:            true,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return MakeDTimestampTZ(timeutil.Now(), time.Microsecond), nil
            },
            Info: "Returns the current wallclock time.",
        },
        Builtin{
            Types:      ArgTypes{},
            ReturnType: fixedReturnType(TypeTimestamp),
            impure:     true,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return MakeDTimestamp(timeutil.Now(), time.Microsecond), nil
            },
            Info: "Returns the current wallclock time.",
        },
    },

    "extract": {
        Builtin{
            Types:      ArgTypes{{"element", TypeString}, {"input", TypeTimestamp}},
            ReturnType: fixedReturnType(TypeInt),
            category:   categoryDateAndTime,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {

                fromTS := args[1].(*DTimestamp)
                timeSpan := strings.ToLower(string(MustBeDString(args[0])))
                return extractStringFromTimestamp(ctx, fromTS.Time, timeSpan)
            },
            Info: "Extracts `element` from `input`. Compatible `elements` are: <br/>&#8226; " +
                "year<br/>&#8226; quarter<br/>&#8226; month<br/>&#8226; week<br/>&#8226; " +
                "dayofweek<br/>&#8226; dayofyear<br/>&#8226; hour<br/>&#8226; minute<br/>&#8226; " +
                "second<br/>&#8226; millisecond<br/>&#8226; microsecond<br/>&#8226; epoch",
        },
        Builtin{
            Types:      ArgTypes{{"element", TypeString}, {"input", TypeDate}},
            ReturnType: fixedReturnType(TypeInt),
            category:   categoryDateAndTime,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                timeSpan := strings.ToLower(string(MustBeDString(args[0])))
                date := args[1].(*DDate)
                fromTSTZ := MakeDTimestampTZFromDate(ctx.GetLocation(), date)
                return extractStringFromTimestamp(ctx, fromTSTZ.Time, timeSpan)
            },
            Info: "Extracts `element` from `input`. Compatible `elements` are: <br/>&#8226; " +
                "year<br/>&#8226; quarter<br/>&#8226; month<br/>&#8226; week<br/>&#8226; " +
                "dayofweek<br/>&#8226; dayofyear<br/>&#8226; hour<br/>&#8226; minute<br/>&#8226; " +
                "second<br/>&#8226; millisecond<br/>&#8226; microsecond<br/>&#8226; epoch",
        },
    },

    "extract_duration": {
        Builtin{
            Types:      ArgTypes{{"element", TypeString}, {"input", TypeInterval}},
            ReturnType: fixedReturnType(TypeInt),
            category:   categoryDateAndTime,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {

                fromInterval := *args[1].(*DInterval)
                timeSpan := strings.ToLower(string(MustBeDString(args[0])))
                switch timeSpan {
                case "hour", "hours":
                    return NewDInt(DInt(fromInterval.Nanos / int64(time.Hour))), nil

                case "minute", "minutes":
                    return NewDInt(DInt(fromInterval.Nanos / int64(time.Minute))), nil

                case "second", "seconds":
                    return NewDInt(DInt(fromInterval.Nanos / int64(time.Second))), nil

                case "millisecond", "milliseconds":

                    return NewDInt(DInt(fromInterval.Nanos / int64(time.Millisecond))), nil

                case "microsecond", "microseconds":
                    return NewDInt(DInt(fromInterval.Nanos / int64(time.Microsecond))), nil

                default:
                    return nil, fmt.Errorf("unsupported timespan: %s", timeSpan)
                }
            },
            Info: "Extracts `element` from `input`. Compatible `elements` are: <br/>&#8226; hour" +
                "<br/>&#8226; minute<br/>&#8226; second<br/>&#8226; millisecond<br/>&#8226; " +
                "microsecond",
        },
    },

    "abs": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Abs(x))), nil
        }, "Calculates the absolute value of `val`."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {
            dd := &DDecimal{}
            dd.Abs(x)
            return dd, nil
        }, "Calculates the absolute value of `val`."),
        Builtin{
            Types:      ArgTypes{{"val", TypeInt}},
            ReturnType: fixedReturnType(TypeInt),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                x := MustBeDInt(args[0])
                switch {
                case x == math.MinInt64:
                    return nil, errAbsOfMinInt64
                case x < 0:
                    return NewDInt(-x), nil
                }
                return args[0], nil
            },
            Info: "Calculates the absolute value of `val`.",
        },
    },

    "acos": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Acos(x))), nil
        }, "Calculates the inverse cosine of `val`."),
    },

    "asin": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Asin(x))), nil
        }, "Calculates the inverse sine of `val`."),
    },

    "atan": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Atan(x))), nil
        }, "Calculates the inverse tangent of `val`."),
    },

    "atan2": {
        floatBuiltin2("x", "y", func(x, y float64) (Datum, error) {
            return NewDFloat(DFloat(math.Atan2(x, y))), nil
        }, "Calculates the inverse tangent of `x`/`y`."),
    },

    "cbrt": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Cbrt(x))), nil
        }, "Calculates the cube root (&#8731;) of `val`."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {
            dd := &DDecimal{}
            _, err := DecimalCtx.Cbrt(&dd.Decimal, x)
            return dd, err
        }, "Calculates the cube root (&#8731;) of `val`."),
    },

    "ceil":    ceilImpl,
    "ceiling": ceilImpl,

    "cos": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Cos(x))), nil
        }, "Calculates the cosine of `val`."),
    },

    "cot": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(1 / math.Tan(x))), nil
        }, "Calculates the cotangent of `val`."),
    },

    "degrees": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(180.0 * x / math.Pi)), nil
        }, "Converts `val` as a radian value to a degree value."),
    },

    "div": {
        floatBuiltin2("x", "y", func(x, y float64) (Datum, error) {
            return NewDFloat(DFloat(math.Trunc(x / y))), nil
        }, "Calculates the integer quotient of `x`/`y`."),
        decimalBuiltin2("x", "y", func(x, y *apd.Decimal) (Datum, error) {
            if y.Sign() == 0 {
                return nil, errDivByZero
            }
            dd := &DDecimal{}
            _, err := HighPrecisionCtx.QuoInteger(&dd.Decimal, x, y)
            return dd, err
        }, "Calculates the integer quotient of `x`/`y`."),
        {
            Types:      ArgTypes{{"x", TypeInt}, {"y", TypeInt}},
            ReturnType: fixedReturnType(TypeInt),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                y := MustBeDInt(args[1])
                if y == 0 {
                    return nil, errDivByZero
                }
                x := MustBeDInt(args[0])
                return NewDInt(x / y), nil
            },
            Info: "Calculates the integer quotient of `x`/`y`.",
        },
    },

    "exp": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Exp(x))), nil
        }, "Calculates *e* ^ `val`."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {
            dd := &DDecimal{}
            _, err := DecimalCtx.Exp(&dd.Decimal, x)
            return dd, err
        }, "Calculates *e* ^ `val`."),
    },

    "floor": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Floor(x))), nil
        }, "Calculates the largest integer not greater than `val`."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {
            dd := &DDecimal{}
            _, err := ExactCtx.Floor(&dd.Decimal, x)
            return dd, err
        }, "Calculates the largest integer not greater than `val`."),
    },

    "isnan": {
        Builtin{

            Types:      ArgTypes{{"val", TypeFloat}},
            ReturnType: fixedReturnType(TypeBool),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return MakeDBool(DBool(isNaN(args[0]))), nil
            },
            Info: "Returns true if `val` is NaN, false otherwise.",
        },
        Builtin{
            Types:      ArgTypes{{"val", TypeDecimal}},
            ReturnType: fixedReturnType(TypeBool),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return MakeDBool(DBool(isNaN(args[0]))), nil
            },
            Info: "Returns true if `val` is NaN, false otherwise.",
        },
    },

    "ln": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Log(x))), nil
        }, "Calculates the natural log of `val`."),
        decimalLogFn(DecimalCtx.Ln, "Calculates the natural log of `val`."),
    },

    "log": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Log10(x))), nil
        }, "Calculates the base 10 log of `val`."),
        decimalLogFn(DecimalCtx.Log10, "Calculates the base 10 log of `val`."),
    },

    "mod": {
        floatBuiltin2("x", "y", func(x, y float64) (Datum, error) {
            return NewDFloat(DFloat(math.Mod(x, y))), nil
        }, "Calculates `x`%`y`."),
        decimalBuiltin2("x", "y", func(x, y *apd.Decimal) (Datum, error) {
            if y.Sign() == 0 {
                return nil, errZeroModulus
            }
            dd := &DDecimal{}
            _, err := HighPrecisionCtx.Rem(&dd.Decimal, x, y)
            return dd, err
        }, "Calculates `x`%`y`."),
        Builtin{
            Types:      ArgTypes{{"x", TypeInt}, {"y", TypeInt}},
            ReturnType: fixedReturnType(TypeInt),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                y := MustBeDInt(args[1])
                if y == 0 {
                    return nil, errZeroModulus
                }
                x := MustBeDInt(args[0])
                return NewDInt(x % y), nil
            },
            Info: "Calculates `x`%`y`.",
        },
    },

    "pi": {
        Builtin{
            Types:      ArgTypes{},
            ReturnType: fixedReturnType(TypeFloat),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return NewDFloat(math.Pi), nil
            },
            Info: "Returns the value for pi (3.141592653589793).",
        },
    },

    "pow":   powImpls,
    "power": powImpls,

    "radians": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(x * math.Pi / 180.0)), nil
        }, "Converts `val` as a degree value to a radians value."),
    },

    "round": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return round(x, 0)
        }, "Rounds `val` to the nearest integer using half to even (banker's) rounding."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {
            return roundDecimal(x, 0)
        }, "Rounds `val` to the nearest integer, half away from zero: "+
            "ROUND(+/-2.4) = +/-2, ROUND(+/-2.5) = +/-3."),
        Builtin{
            Types:      ArgTypes{{"input", TypeFloat}, {"decimal_accuracy", TypeInt}},
            ReturnType: fixedReturnType(TypeFloat),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return round(float64(*args[0].(*DFloat)), int64(MustBeDInt(args[1])))
            },
            Info: "Keeps `decimal_accuracy` number of figures to the right of the zero position " +
                " in `input` using half to even (banker's) rounding.",
        },
        Builtin{
            Types:      ArgTypes{{"input", TypeDecimal}, {"decimal_accuracy", TypeInt}},
            ReturnType: fixedReturnType(TypeDecimal),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {

                scale := int32(MustBeDInt(args[1]))
                return roundDecimal(&args[0].(*DDecimal).Decimal, scale)
            },
            Info: "Keeps `decimal_accuracy` number of figures to the right of the zero position " +
                " in `input using half away from zero rounding. If `decimal_accuracy` " +
                "is not in the range -2^31...(2^31-1), the results are undefined.",
        },
    },

    "sin": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Sin(x))), nil
        }, "Calculates the sine of `val`."),
    },

    "sign": {
        floatBuiltin1(func(x float64) (Datum, error) {
            switch {
            case x < 0:
                return NewDFloat(-1), nil
            case x == 0:
                return NewDFloat(0), nil
            }
            return NewDFloat(1), nil
        }, "Determines the sign of `val`: **1** for positive; **0** for 0 values; **-1** for "+
            "negative."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {
            d := &DDecimal{}
            d.Decimal.SetCoefficient(int64(x.Sign()))
            return d, nil
        }, "Determines the sign of `val`: **1** for positive; **0** for 0 values; **-1** for "+
            "negative."),
        Builtin{
            Types:      ArgTypes{{"val", TypeInt}},
            ReturnType: fixedReturnType(TypeInt),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                x := MustBeDInt(args[0])
                switch {
                case x < 0:
                    return NewDInt(-1), nil
                case x == 0:
                    return DZero, nil
                }
                return NewDInt(1), nil
            },
            Info: "Determines the sign of `val`: **1** for positive; **0** for 0 values; **-1** " +
                "for negative.",
        },
    },

    "sqrt": {
        floatBuiltin1(func(x float64) (Datum, error) {

            if x < 0 {
                return nil, errSqrtOfNegNumber
            }
            return NewDFloat(DFloat(math.Sqrt(x))), nil
        }, "Calculates the square root of `val`."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {
            if x.Sign() < 0 {
                return nil, errSqrtOfNegNumber
            }
            dd := &DDecimal{}
            _, err := DecimalCtx.Sqrt(&dd.Decimal, x)
            return dd, err
        }, "Calculates the square root of `val`."),
    },

    "tan": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Tan(x))), nil
        }, "Calculates the tangent of `val`."),
    },

    "trunc": {
        floatBuiltin1(func(x float64) (Datum, error) {
            return NewDFloat(DFloat(math.Trunc(x))), nil
        }, "Truncates the decimal values of `val`."),
        decimalBuiltin1(func(x *apd.Decimal) (Datum, error) {

            dd := &DDecimal{}
            frac := new(apd.Decimal)
            x.Modf(&dd.Decimal, frac)
            return dd, nil
        }, "Truncates the decimal values of `val`."),
    },

    "to_english": {
        Builtin{
            Types:      ArgTypes{{"val", TypeInt}},
            ReturnType: fixedReturnType(TypeString),
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                val := int(*args[0].(*DInt))
                var buf bytes.Buffer
                if val < 0 {
                    buf.WriteString("minus-")
                    val = -val
                }
                var digits []string
                digits = append(digits, digitNames[val%10])
                for val > 9 {
                    val /= 10
                    digits = append(digits, digitNames[val%10])
                }
                for i := len(digits) - 1; i >= 0; i-- {
                    if i < len(digits)-1 {
                        buf.WriteByte('-')
                    }
                    buf.WriteString(digits[i])
                }
                return NewDString(buf.String()), nil
            },
            category: categoryString,
            Info:     "This function enunciates the value of its argument using English cardinals.",
        },
    },

    "array_length": {
        Builtin{
            Types:      ArgTypes{{"input", TypeAnyArray}, {"array_dimension", TypeInt}},
            ReturnType: fixedReturnType(TypeInt),
            category:   categorySystemInfo,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                arr := MustBeDArray(args[0])
                dimen := int64(MustBeDInt(args[1]))
                return arrayLength(arr, dimen), nil
            },
            Info: "Calculates the length of `input` on the provided `array_dimension`. However, " +
                "because CockroachDB doesn't yet support multi-dimensional arrays, the only supported" +
                " `array_dimension` is **1**.",
        },
    },

    "array_lower": {
        Builtin{
            Types:      ArgTypes{{"input", TypeAnyArray}, {"array_dimension", TypeInt}},
            ReturnType: fixedReturnType(TypeInt),
            category:   categorySystemInfo,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                arr := MustBeDArray(args[0])
                dimen := int64(MustBeDInt(args[1]))
                return arrayLower(arr, dimen), nil
            },
            Info: "Calculates the minimum value of `input` on the provided `array_dimension`. " +
                "However, because CockroachDB doesn't yet support multi-dimensional arrays, the only " +
                "supported `array_dimension` is **1**.",
        },
    },

    "array_upper": {
        Builtin{
            Types:      ArgTypes{{"input", TypeAnyArray}, {"array_dimension", TypeInt}},
            ReturnType: fixedReturnType(TypeInt),
            category:   categorySystemInfo,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                arr := MustBeDArray(args[0])
                dimen := int64(MustBeDInt(args[1]))
                return arrayLength(arr, dimen), nil
            },
            Info: "Calculates the maximum value of `input` on the provided `array_dimension`. " +
                "However, because CockroachDB doesn't yet support multi-dimensional arrays, the only " +
                "supported `array_dimension` is **1**.",
        },
    },

    "version": {
        Builtin{
            Types:      ArgTypes{},
            ReturnType: fixedReturnType(TypeString),
            category:   categorySystemInfo,
            fn: func(_ *EvalContext, args Datums) (Datum, error) {
                return NewDString(build.GetInfo().Short()), nil
            },
            Info: "Returns the node's version of CockroachDB.",
        },
    },

    "current_database": {
        Builtin{
            Types:      ArgTypes{},
            ReturnType: fixedReturnType(TypeString),
            category:   categorySystemInfo,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                if len(ctx.Database) == 0 {
                    return DNull, nil
                }
                return NewDString(ctx.Database), nil
            },
            Info: "Returns the current database.",
        },
    },

    "current_schema": {
        Builtin{
            Types:      ArgTypes{},
            ReturnType: fixedReturnType(TypeString),
            category:   categorySystemInfo,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                if len(ctx.Database) == 0 {
                    return DNull, nil
                }
                return NewDString(ctx.Database), nil
            },
            Info: "Returns the current schema. This function is provided for " +
                "compatibility with PostgreSQL. For a new CockroachDB application, " +
                "consider using current_database() instead.",
        },
    },

    "current_schemas": {
        Builtin{
            Types:        ArgTypes{{"include_pg_catalog", TypeBool}},
            ReturnType:   fixedReturnType(TypeStringArray),
            category:     categorySystemInfo,
            ctxDependent: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                includePgCatalog := *(args[0].(*DBool))
                schemas := NewDArray(TypeString)
                if len(ctx.Database) != 0 {
                    if err := schemas.Append(NewDString(ctx.Database)); err != nil {
                        return nil, err
                    }
                }
                for _, p := range ctx.SearchPath {
                    if !includePgCatalog && p == "pg_catalog" {
                        continue
                    }
                    if err := schemas.Append(NewDString(p)); err != nil {
                        return nil, err
                    }
                }
                return schemas, nil
            },
            Info: "Returns the current search path for unqualified names.",
        },
    },

    "crdb_internal.force_internal_error": {
        Builtin{
            Types:      ArgTypes{{"msg", TypeString}},
            ReturnType: fixedReturnType(TypeInt),
            impure:     true,
            privileged: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                msg := string(*args[0].(*DString))
                return nil, pgerror.NewError(pgerror.CodeInternalError, msg)
            },
            category: categorySystemInfo,
            Info:     "This function is used only by CockroachDB's developers for testing purposes.",
        },
    },

    "crdb_internal.force_panic": {
        Builtin{
            Types:      ArgTypes{{"msg", TypeString}},
            ReturnType: fixedReturnType(TypeInt),
            impure:     true,
            privileged: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                msg := string(*args[0].(*DString))
                panic(msg)
            },
            category: categorySystemInfo,
            Info:     "This function is used only by CockroachDB's developers for testing purposes.",
        },
    },

    "crdb_internal.force_retry": {
        Builtin{
            Types:      ArgTypes{{"val", TypeInterval}},
            ReturnType: fixedReturnType(TypeInt),
            impure:     true,
            privileged: true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                minDuration := args[0].(*DInterval).Duration
                elapsed := duration.Duration{
                    Nanos: int64(ctx.stmtTimestamp.Sub(ctx.txnTimestamp)),
                }
                if elapsed.Compare(minDuration) < 0 {
                    return nil, roachpb.NewHandledRetryableTxnError(
                        "forced by crdb_internal.force_retry()",
                        nil,
                        roachpb.Transaction{})
                }
                return DZero, nil
            },
            category: categorySystemInfo,
            Info:     "This function is used only by CockroachDB's developers for testing purposes.",
        },
        Builtin{
            Types: ArgTypes{
                {"val", TypeInterval},
                {"txnID", TypeString}},
            ReturnType: fixedReturnType(TypeInt),
            impure:     true,
            fn: func(ctx *EvalContext, args Datums) (Datum, error) {
                minDuration := args[0].(*DInterval).Duration
                txnID := args[1].(*DString)
                elapsed := duration.Duration{
                    Nanos: int64(ctx.stmtTimestamp.Sub(ctx.txnTimestamp)),
                }
                if elapsed.Compare(minDuration) < 0 {
                    uuid, err := uuid.FromString(string(*txnID))
                    if err != nil {
                        return nil, err
                    }
                    return nil, roachpb.NewHandledRetryableTxnError(
                        "forced by crdb_internal.force_retry()", &uuid, roachpb.Transaction{})
                }
                return DZero, nil
            },
            category: categorySystemInfo,
            Info:     "This function is used only by CockroachDB's developers for testing purposes.",
        },
    },
}

Builtins contains the built-in functions indexed by name.

var CmpOps = map[ComparisonOperator]cmpOpOverload{
    EQ: {
        CmpOp{
            LeftType:  TypeString,
            RightType: TypeString,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeCollatedString,
            RightType: TypeCollatedString,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeBytes,
            RightType: TypeBytes,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeBool,
            RightType: TypeBool,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeInt,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeFloat,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeDecimal,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeInt,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeFloat,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeInt,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeDecimal,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeFloat,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeDecimal,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeDate,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeDate,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeDate,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeInterval,
            RightType: TypeInterval,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeOid,
            RightType: TypeOid,
            fn:        cmpOpScalarEQFn,
        },
        CmpOp{
            LeftType:  TypeTuple,
            RightType: TypeTuple,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return cmpOpTupleFn(ctx, *left.(*DTuple), *right.(*DTuple), EQ), nil
            },
        },
    },

    LT: {
        CmpOp{
            LeftType:  TypeString,
            RightType: TypeString,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeCollatedString,
            RightType: TypeCollatedString,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeBytes,
            RightType: TypeBytes,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeBool,
            RightType: TypeBool,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeInt,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeFloat,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeDecimal,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeInt,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeFloat,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeInt,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeDecimal,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeFloat,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeDecimal,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeDate,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeDate,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeDate,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeInterval,
            RightType: TypeInterval,
            fn:        cmpOpScalarLTFn,
        },
        CmpOp{
            LeftType:  TypeTuple,
            RightType: TypeTuple,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return cmpOpTupleFn(ctx, *left.(*DTuple), *right.(*DTuple), LT), nil
            },
        },
    },

    LE: {
        CmpOp{
            LeftType:  TypeString,
            RightType: TypeString,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeCollatedString,
            RightType: TypeCollatedString,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeBytes,
            RightType: TypeBytes,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeBool,
            RightType: TypeBool,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeInt,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeFloat,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeDecimal,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeInt,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeFloat,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeInt,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeInt,
            RightType: TypeDecimal,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeDecimal,
            RightType: TypeFloat,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeFloat,
            RightType: TypeDecimal,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeDate,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeTimestampTZ,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeDate,
            RightType: TypeTimestamp,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeTimestampTZ,
            RightType: TypeDate,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeTimestamp,
            RightType: TypeDate,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeInterval,
            RightType: TypeInterval,
            fn:        cmpOpScalarLEFn,
        },
        CmpOp{
            LeftType:  TypeTuple,
            RightType: TypeTuple,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return cmpOpTupleFn(ctx, *left.(*DTuple), *right.(*DTuple), LE), nil
            },
        },
    },

    In: {
        makeEvalTupleIn(TypeBool),
        makeEvalTupleIn(TypeInt),
        makeEvalTupleIn(TypeFloat),
        makeEvalTupleIn(TypeDecimal),
        makeEvalTupleIn(TypeString),
        makeEvalTupleIn(TypeCollatedString),
        makeEvalTupleIn(TypeBytes),
        makeEvalTupleIn(TypeDate),
        makeEvalTupleIn(TypeTimestamp),
        makeEvalTupleIn(TypeTimestampTZ),
        makeEvalTupleIn(TypeInterval),
        makeEvalTupleIn(TypeTuple),
    },

    Like: {
        CmpOp{
            LeftType:  TypeString,
            RightType: TypeString,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return matchLike(ctx, left, right, false)
            },
        },
    },

    ILike: {
        CmpOp{
            LeftType:  TypeString,
            RightType: TypeString,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                return matchLike(ctx, left, right, true)
            },
        },
    },

    SimilarTo: {
        CmpOp{
            LeftType:  TypeString,
            RightType: TypeString,
            fn: func(ctx *EvalContext, left Datum, right Datum) (Datum, error) {
                key := similarToKey(MustBeDString(right))
                return matchRegexpWithKey(ctx, left, key)
            },
        },
    },

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

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

CmpOps contains the comparison operations indexed by operation type.

var Generators = map[string][]Builtin{
    "generate_series": {
        makeGeneratorBuiltin(
            ArgTypes{{"start", TypeInt}, {"end", TypeInt}},
            TTuple{TypeInt},
            makeSeriesGenerator,
            "Produces a virtual table containing the integer values from `start` to `end`, inclusive.",
        ),
        makeGeneratorBuiltin(
            ArgTypes{{"start", TypeInt}, {"end", TypeInt}, {"step", TypeInt}},
            TTuple{TypeInt},
            makeSeriesGenerator,
            "Produces a virtual table containing the integer values from `start` to `end`, inclusive, by increment of `step`.",
        ),
    },
    "unnest": {
        makeGeneratorBuiltinWithReturnType(
            ArgTypes{{"input", TypeAnyArray}},
            func(args []TypedExpr) Type {
                if len(args) == 0 {
                    return unknownReturnType
                }
                return TTable{Cols: TTuple{args[0].ResolvedType().(TArray).Typ}}
            },
            makeArrayGenerator,
            "Returns the input array as a set of rows",
        ),
    },
}

Generators is a map from name to slice of Builtins for all built-in generators.

var OidToType = map[oid.Oid]Type{
    oid.T_anyelement:   TypeAny,
    oid.T_bool:         TypeBool,
    oid.T_bytea:        TypeBytes,
    oid.T_date:         TypeDate,
    oid.T_float4:       typeFloat4,
    oid.T_float8:       TypeFloat,
    oid.T_int2:         typeInt2,
    oid.T_int4:         typeInt4,
    oid.T_int8:         TypeInt,
    oid.T_int2vector:   TypeIntVector,
    oid.T_interval:     TypeInterval,
    oid.T_name:         TypeName,
    oid.T_numeric:      TypeDecimal,
    oid.T_oid:          TypeOid,
    oid.T_regclass:     TypeRegClass,
    oid.T_regnamespace: TypeRegNamespace,
    oid.T_regproc:      TypeRegProc,
    oid.T_regprocedure: TypeRegProcedure,
    oid.T_regtype:      TypeRegType,
    oid.T__text:        TypeStringArray,
    oid.T__int2:        typeInt2Array,
    oid.T__int4:        typeInt4Array,
    oid.T__int8:        TypeIntArray,
    oid.T_record:       TypeTuple,
    oid.T_text:         TypeString,
    oid.T_timestamp:    TypeTimestamp,
    oid.T_timestamptz:  TypeTimestampTZ,
    oid.T_varchar:      typeVarChar,
}

OidToType maps Postgres object IDs to CockroachDB types.

var StarDatumInstance = &StarDatum{}

StarDatumInstance can be used as common instance for all uses of StarDatum.

var UnaryOps = map[UnaryOperator]unaryOpOverload{
    UnaryPlus: {
        UnaryOp{
            Typ:        TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return d, nil
            },
        },
        UnaryOp{
            Typ:        TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return d, nil
            },
        },
        UnaryOp{
            Typ:        TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return d, nil
            },
        },
    },

    UnaryMinus: {
        UnaryOp{
            Typ:        TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                i := MustBeDInt(d)
                if i == math.MinInt64 {
                    return nil, errIntOutOfRange
                }
                return NewDInt(-i), nil
            },
        },
        UnaryOp{
            Typ:        TypeFloat,
            ReturnType: TypeFloat,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return NewDFloat(-*d.(*DFloat)), nil
            },
        },
        UnaryOp{
            Typ:        TypeDecimal,
            ReturnType: TypeDecimal,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                dec := &d.(*DDecimal).Decimal
                dd := &DDecimal{}
                dd.Decimal.Neg(dec)
                return dd, nil
            },
        },
        UnaryOp{
            Typ:        TypeInterval,
            ReturnType: TypeInterval,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                i := d.(*DInterval).Duration
                i.Nanos = -i.Nanos
                i.Days = -i.Days
                i.Months = -i.Months
                return &DInterval{Duration: i}, nil
            },
        },
    },

    UnaryComplement: {
        UnaryOp{
            Typ:        TypeInt,
            ReturnType: TypeInt,
            fn: func(_ *EvalContext, d Datum) (Datum, error) {
                return NewDInt(^MustBeDInt(d)), nil
            },
        },
    },
}

UnaryOps contains the unary operations indexed by operation type.

func AsString Uses

func AsString(n NodeFormatter) string

AsString pretty prints a node to a string.

func AsStringWithFlags Uses

func AsStringWithFlags(n NodeFormatter, f FmtFlags) string

AsStringWithFlags pretty prints a node to a string given specific flags.

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

func ExprDebugString(expr Expr) string

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

func FindEqualComparisonFunction Uses

func FindEqualComparisonFunction(
    leftType, rightType Type,
) (func(*EvalContext, Datum, Datum) (Datum, error), bool)

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

func FormatNode Uses

func FormatNode(buf *bytes.Buffer, f FmtFlags, n NodeFormatter)

FormatNode recurses into a node for pretty-printing. Flag-driven special cases can hook into this.

func HasReturningClause Uses

func HasReturningClause(clause ReturningClause) bool

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

func IsIdentAggregate Uses

func IsIdentAggregate(f AggregateFunc) bool

IsIdentAggregate returns true for identAggregate.

func IsNumericOne Uses

func IsNumericOne(expr TypedExpr) bool

IsNumericOne returns true if the datum is a number and equal to one.

func IsNumericZero Uses

func IsNumericZero(expr TypedExpr) bool

IsNumericZero returns true if the datum is a number and equal to zero.

func PGDisplayName Uses

func PGDisplayName(typ Type) string

PGDisplayName returns the Postgres display name for a given type.

func PGIOBuiltinPrefix Uses

func PGIOBuiltinPrefix(typ Type) string

PGIOBuiltinPrefix returns the string prefix to a type's IO functions. This is either the type's postgres display name or the type's postgres display name plus an underscore, depending on the type.

func ReNormalizeName Uses

func ReNormalizeName(name string) string

ReNormalizeName performs the same work as NormalizeName but when the string originates from the database. We define a different function so as to be able to track usage of this function (cf. #8200).

func Serialize Uses

func Serialize(n NodeFormatter) string

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

func SimilarEscape Uses

func SimilarEscape(pattern string) string

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

func 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 ValidateRestartCheckpoint Uses

func ValidateRestartCheckpoint(savepoint string) error

ValidateRestartCheckpoint checks that a checkpoint name is our magic restart value. We accept everything with the desired prefix because at least the C++ libpqxx appends sequence numbers to the savepoint name specified by the user.

func WalkExprConst Uses

func WalkExprConst(v Visitor, expr Expr)

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

type AggregateFunc Uses

type AggregateFunc interface {
    // Add accumulates the passed datum into the AggregateFunc.
    Add(context.Context, 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)

    // 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)
}

AggregateFunc accumulates the result of a function of a Datum.

func NewIdentAggregate Uses

func NewIdentAggregate(*EvalContext) AggregateFunc

NewIdentAggregate returns an identAggregate (see comment on struct).

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type AliasedTableExpr Uses

type AliasedTableExpr struct {
    Expr       TableExpr
    Hints      *IndexHints
    Ordinality bool
    As         AliasClause
}

AliasedTableExpr represents a table expression coupled with an optional alias.

func (*AliasedTableExpr) Format Uses

func (node *AliasedTableExpr) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AliasedTableExpr) String Uses

func (node *AliasedTableExpr) String() string

type AllColumnsSelector Uses

type AllColumnsSelector struct {
    TableName
}

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AllColumnsSelector) NormalizeVarName Uses

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

NormalizeVarName is a no-op for AllColumnsSelector (already normalized)

func (*AllColumnsSelector) ResolvedType Uses

func (*AllColumnsSelector) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*AllColumnsSelector) String Uses

func (a *AllColumnsSelector) String() string

func (*AllColumnsSelector) TypeCheck Uses

func (expr *AllColumnsSelector) TypeCheck(_ *SemaContext, desired Type) (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 {
    Database Name
}

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AllTablesSelector) NormalizeTablePattern Uses

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

NormalizeTablePattern implements the TablePattern interface.

func (*AllTablesSelector) QualifyWithDatabase Uses

func (at *AllTablesSelector) QualifyWithDatabase(database string) error

QualifyWithDatabase adds an indirection for the database, if it's missing. It transforms: * -> database.*

func (*AllTablesSelector) String Uses

func (at *AllTablesSelector) String() string

type AlterTable Uses

type AlterTable struct {
    IfExists bool
    Table    NormalizableTableName
    Cmds     AlterTableCmds
}

AlterTable represents an ALTER TABLE statement.

func (*AlterTable) Format Uses

func (node *AlterTable) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

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

AlterTableAddColumn represents an ADD COLUMN command.

func (*AlterTableAddColumn) Format Uses

func (node *AlterTableAddColumn) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AlterTableAddColumn) String Uses

func (n *AlterTableAddColumn) String() string

type AlterTableAddConstraint Uses

type AlterTableAddConstraint struct {
    ConstraintDef      ConstraintTableDef
    ValidationBehavior ValidationBehavior
}

AlterTableAddConstraint represents an ADD CONSTRAINT command.

func (*AlterTableAddConstraint) Format Uses

func (node *AlterTableAddConstraint) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AlterTableAddConstraint) String Uses

func (n *AlterTableAddConstraint) String() string

type AlterTableCmd Uses

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

AlterTableCmd represents a table modification operation.

type AlterTableCmds Uses

type AlterTableCmds []AlterTableCmd

AlterTableCmds represents a list of table alterations.

func (AlterTableCmds) Format Uses

func (node AlterTableCmds) Format(buf *bytes.Buffer, f FmtFlags)

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

AlterTableDropColumn represents a DROP COLUMN command.

func (*AlterTableDropColumn) Format Uses

func (node *AlterTableDropColumn) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AlterTableDropColumn) String Uses

func (n *AlterTableDropColumn) String() string

type AlterTableDropConstraint Uses

type AlterTableDropConstraint struct {
    IfExists     bool
    Constraint   Name
    DropBehavior DropBehavior
}

AlterTableDropConstraint represents a DROP CONSTRAINT command.

func (*AlterTableDropConstraint) Format Uses

func (node *AlterTableDropConstraint) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AlterTableDropConstraint) String Uses

func (n *AlterTableDropConstraint) String() string

type AlterTableDropNotNull Uses

type AlterTableDropNotNull struct {
    Column Name
    // contains filtered or unexported fields
}

AlterTableDropNotNull represents an ALTER COLUMN DROP NOT NULL command.

func (*AlterTableDropNotNull) Format Uses

func (node *AlterTableDropNotNull) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AlterTableDropNotNull) GetColumn Uses

func (node *AlterTableDropNotNull) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableDropNotNull) String Uses

func (n *AlterTableDropNotNull) String() string

type AlterTableSetDefault Uses

type AlterTableSetDefault struct {
    Column  Name
    Default Expr
    // contains filtered or unexported fields
}

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

func (*AlterTableSetDefault) Format Uses

func (node *AlterTableSetDefault) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AlterTableSetDefault) GetColumn Uses

func (node *AlterTableSetDefault) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableSetDefault) String Uses

func (n *AlterTableSetDefault) String() string

type AlterTableValidateConstraint Uses

type AlterTableValidateConstraint struct {
    Constraint Name
}

AlterTableValidateConstraint represents a VALIDATE CONSTRAINT command.

func (*AlterTableValidateConstraint) Format Uses

func (node *AlterTableValidateConstraint) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (AndExpr) ResolvedType Uses

func (ta AndExpr) ResolvedType() Type

func (*AndExpr) String Uses

func (node *AndExpr) String() string

func (*AndExpr) TypeCheck Uses

func (expr *AndExpr) TypeCheck(ctx *SemaContext, desired Type) (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 CastTargetType
    // contains filtered or unexported fields
}

AnnotateTypeExpr represents a ANNOTATE_TYPE(expr, type) expression.

func (*AnnotateTypeExpr) Format Uses

func (node *AnnotateTypeExpr) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AnnotateTypeExpr) String Uses

func (node *AnnotateTypeExpr) String() string

func (*AnnotateTypeExpr) TypeCheck Uses

func (expr *AnnotateTypeExpr) TypeCheck(ctx *SemaContext, desired Type) (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 ArgTypes Uses

type ArgTypes []struct {
    Name string
    Typ  Type
}

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) Length Uses

func (a ArgTypes) Length() int

Length implements the typeList interface.

func (ArgTypes) String Uses

func (a ArgTypes) String() string

func (ArgTypes) Types Uses

func (a ArgTypes) Types() []Type

Types implements the typeList interface.

type Array Uses

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

Array represents an array constructor.

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (Array) ResolvedType Uses

func (ta Array) ResolvedType() Type

func (*Array) String Uses

func (node *Array) String() string

func (*Array) TypeCheck Uses

func (expr *Array) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Array) Walk Uses

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

Walk implements the Expr interface.

type ArrayColType Uses

type ArrayColType struct {
    Name string
    // ParamTyp is the type of the elements in this array.
    ParamType   ColumnType
    BoundsExprs Exprs
}

ArrayColType represents an ARRAY column type.

func (*ArrayColType) Format Uses

func (node *ArrayColType) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*ArrayColType) String Uses

func (node *ArrayColType) String() string

type ArrayFlatten Uses

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

ArrayFlatten represents a subquery array constructor.

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (ArrayFlatten) ResolvedType Uses

func (ta ArrayFlatten) ResolvedType() Type

func (*ArrayFlatten) String Uses

func (node *ArrayFlatten) String() string

func (*ArrayFlatten) TypeCheck Uses

func (expr *ArrayFlatten) TypeCheck(ctx *SemaContext, desired Type) (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(buf *bytes.Buffer, f FmtFlags)

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type AsOfClause Uses

type AsOfClause struct {
    Expr Expr
}

AsOfClause represents an as of time.

func (AsOfClause) Format Uses

func (a AsOfClause) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type Backup Uses

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

Backup represents a BACKUP statement.

func (*Backup) Format Uses

func (node *Backup) Format(buf *bytes.Buffer, f FmtFlags)

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

type BeginTransaction struct {
    Isolation    IsolationLevel
    UserPriority UserPriority
}

BeginTransaction represents a BEGIN statement

func (*BeginTransaction) Format Uses

func (node *BeginTransaction) Format(buf *bytes.Buffer, f FmtFlags)

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   Type
    RightType  Type
    ReturnType Type
    // contains filtered or unexported fields
}

BinOp is a binary operator.

type BinaryExpr Uses

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

BinaryExpr represents a binary value expression.

func (*BinaryExpr) Eval Uses

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

Eval implements the TypedExpr interface.

func (*BinaryExpr) Format Uses

func (node *BinaryExpr) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (BinaryExpr) ResolvedType Uses

func (ta BinaryExpr) ResolvedType() Type

func (*BinaryExpr) String Uses

func (node *BinaryExpr) String() string

func (*BinaryExpr) TypeCheck Uses

func (expr *BinaryExpr) TypeCheck(ctx *SemaContext, desired Type) (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
)

BinaryExpr.Operator

func (BinaryOperator) String Uses

func (i BinaryOperator) String() string

type BoolColType Uses

type BoolColType struct {
    Name string
}

BoolColType represents a BOOLEAN type.

func (*BoolColType) Format Uses

func (node *BoolColType) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*BoolColType) String Uses

func (node *BoolColType) String() string

type Builtin Uses

type Builtin struct {
    Types      typeList
    ReturnType returnTyper

    // Info is a description of the function, which is surfaced on the CockroachDB
    // docs site on the "Functions and Operators" page. Descriptions typically use
    // third-person with the function as an implicit subject (e.g. "Calculates
    // infinity"), but should focus more on ease of understanding so other structures
    // might be more appropriate.
    Info string

    AggregateFunc func([]Type, *EvalContext) AggregateFunc
    WindowFunc    func([]Type, *EvalContext) WindowFunc
    // contains filtered or unexported fields
}

Builtin is a built-in function.

func (Builtin) Category Uses

func (b Builtin) Category() string

Category is used to categorize a function (for documentation purposes).

func (Builtin) Class Uses

func (b Builtin) Class() FunctionClass

Class returns the FunctionClass of this builtin.

func (Builtin) ContextDependent Uses

func (b Builtin) ContextDependent() bool

ContextDependent returns true if this builtin depends on data stored in the EvalContext.

func (Builtin) FixedReturnType Uses

func (b Builtin) FixedReturnType() Type

FixedReturnType returns a fixed type that the function returns, returning Any if the return type is based on the function's arguments.

func (Builtin) Impure Uses

func (b Builtin) Impure() bool

Impure returns false if this builtin is a pure function of its inputs.

func (Builtin) Signature Uses

func (b Builtin) Signature() string

Signature returns a human-readable signature.

type BytesColType Uses

type BytesColType struct {
    Name string
}

BytesColType represents a BYTES or BLOB type.

func (*BytesColType) Format Uses

func (node *BytesColType) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*BytesColType) String Uses

func (node *BytesColType) 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 (*CaseExpr) CopyNode Uses

func (expr *CaseExpr) CopyNode() *CaseExpr

CopyNode makes a copy of this Expr without recursing in any child Exprs.

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (CaseExpr) ResolvedType Uses

func (ta CaseExpr) ResolvedType() Type

func (*CaseExpr) String Uses

func (node *CaseExpr) String() string

func (*CaseExpr) TypeCheck Uses

func (expr *CaseExpr) TypeCheck(ctx *SemaContext, desired Type) (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 CastTargetType
    // contains filtered or unexported fields
}

CastExpr represents a CAST(expr AS type) expression.

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (CastExpr) ResolvedType Uses

func (ta CastExpr) ResolvedType() Type

func (*CastExpr) String Uses

func (node *CastExpr) String() string

func (*CastExpr) TypeCheck Uses

func (expr *CastExpr) TypeCheck(ctx *SemaContext, _ Type) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CastExpr) Walk Uses

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

Walk implements the Expr interface.

type CastTargetType Uses

type CastTargetType interface {
    fmt.Stringer
    NodeFormatter
    // contains filtered or unexported methods
}

CastTargetType represents a type that is a valid cast target.

type CheckConstraintTableDef Uses

type CheckConstraintTableDef struct {
    Name Name
    Expr Expr
}

CheckConstraintTableDef represents a check constraint within a CREATE TABLE statement.

func (*CheckConstraintTableDef) Format Uses

func (node *CheckConstraintTableDef) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type CmpOp Uses

type CmpOp struct {
    LeftType  Type
    RightType Type
    // 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 (*CoalesceExpr) CopyNode Uses

func (expr *CoalesceExpr) CopyNode() *CoalesceExpr

CopyNode makes a copy of this Expr without recursing in any child Exprs.

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (CoalesceExpr) ResolvedType Uses

func (ta CoalesceExpr) ResolvedType() Type

func (*CoalesceExpr) String Uses

func (node *CoalesceExpr) String() string

func (*CoalesceExpr) TypeCheck Uses

func (expr *CoalesceExpr) TypeCheck(ctx *SemaContext, desired Type) (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 (*CollateExpr) Eval Uses

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

Eval implements the TypedExpr interface.

func (*CollateExpr) Format Uses

func (node *CollateExpr) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (CollateExpr) ResolvedType Uses

func (ta CollateExpr) ResolvedType() Type

func (*CollateExpr) String Uses

func (node *CollateExpr) String() string

func (*CollateExpr) TypeCheck Uses

func (expr *CollateExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CollateExpr) Walk Uses

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

Walk implements the Expr interface.

type CollatedStringColType Uses

type CollatedStringColType struct {
    Name   string
    N      int
    Locale string
}

CollatedStringColType represents a STRING, CHAR or VARCHAR type with a collation locale.

func (*CollatedStringColType) Format Uses

func (node *CollatedStringColType) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*CollatedStringColType) String Uses

func (node *CollatedStringColType) String() string

type CollationEnvironment Uses

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

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

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

type ColumnDefault struct {
    Expr Expr
}

ColumnDefault represents a DEFAULT clause for a column.

type ColumnFKConstraint Uses

type ColumnFKConstraint struct {
    Table NormalizableTableName
    Col   Name // empty-string means use PK
}

ColumnFKConstraint represents a FK-constaint on a column.

type ColumnFamilyConstraint Uses

type ColumnFamilyConstraint struct {
    Family      Name
    Create      bool
    IfNotExists bool
}

ColumnFamilyConstraint represents FAMILY on a column.

type ColumnID Uses

type ColumnID uint32

ColumnID is a custom type for ColumnDescriptor IDs.

type ColumnItem Uses

type ColumnItem struct {
    // TableName holds the table prefix, if the name refers to a column.
    TableName TableName
    // ColumnName names the designated column.
    ColumnName Name
    // Selector defines which sub-part of the variable is being
    // accessed.
    Selector NameParts
}

ColumnItem corresponds to the name of a column or sub-item of a column in an expression.

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(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*ColumnItem) NormalizeVarName Uses

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

NormalizeVarName is a no-op for ColumnItem (already normalized)

func (*ColumnItem) ResolvedType Uses

func (c *ColumnItem) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*ColumnItem) String Uses

func (c *ColumnItem) String() string

func (*ColumnItem) TypeCheck Uses

func (expr *ColumnItem) TypeCheck(_ *SemaContext, desired Type) (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. Although, the ColumnItem ought to be replaced to an IndexedVar before the points the VariableExpr interface is used.

func (*ColumnItem) Walk Uses

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

Walk implements the Expr interface.

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

type ColumnTableDef struct {
    Name     Name
    Type     ColumnType
    Nullable struct {
        Nullability    Nullability
        ConstraintName Name
    }
    PrimaryKey           bool
    Unique               bool
    UniqueConstraintName Name
    DefaultExpr          struct {
        Expr           Expr
        ConstraintName Name
    }
    CheckExprs []ColumnTableDefCheckExpr
    References struct {
        Table          NormalizableTableName
        Col            Name
        ConstraintName Name
    }
    Family struct {
        Name        Name
        Create      bool
        IfNotExists bool
    }
}

ColumnTableDef represents a column definition within a CREATE TABLE statement.

func (*ColumnTableDef) Format Uses

func (node *ColumnTableDef) Format(buf *bytes.Buffer, f FmtFlags)

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.

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

type ColumnType interface {
    CastTargetType
    // contains filtered or unexported methods
}

ColumnType represents a type in a column definition.

func DatumTypeToColumnType Uses

func DatumTypeToColumnType(t Type) (ColumnType, error)

DatumTypeToColumnType produces a SQL column type equivalent to the given Datum type. Used to generate CastExpr nodes during normalization.

type CommitTransaction Uses

type CommitTransaction struct{}

CommitTransaction represents a COMMIT statement.

func (*CommitTransaction) Format Uses

func (node *CommitTransaction) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*CommitTransaction) StatementTag Uses

func (*CommitTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommitTransaction) StatementType Uses

func (*CommitTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommitTransaction) String Uses

func (n *CommitTransaction) String() string

type ComparisonExpr Uses

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

ComparisonExpr represents a two-value comparison expression.

func NewTypedComparisonExpr Uses

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

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

func (*ComparisonExpr) Eval Uses

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

Eval implements the TypedExpr interface.

func (*ComparisonExpr) Format Uses

func (node *ComparisonExpr) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*ComparisonExpr) IsMixedTypeComparison Uses

func (node *ComparisonExpr) IsMixedTypeComparison() bool

IsMixedTypeComparison returns true when the two sides of a comparison operator have different types.

func (ComparisonExpr) ResolvedType Uses

func (ta ComparisonExpr) ResolvedType() Type

func (*ComparisonExpr) String Uses

func (node *ComparisonExpr) String() string

func (*ComparisonExpr) TypeCheck Uses

func (expr *ComparisonExpr) TypeCheck(ctx *SemaContext, desired Type) (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
    Is
    IsNot

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

ComparisonExpr.Operator

func (ComparisonOperator) String Uses

func (i ComparisonOperator) String() string

type CompositeDatum Uses

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

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

type 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() []Type
    // ResolveAsType resolves the Constant as the Datum type specified, or returns an
    // error if the Constant could not be resolved as that type. The method should only
    // be passed a type returned from AvailableTypes and should never be called more than
    // once for a given Constant.
    ResolveAsType(*SemaContext, Type) (Datum, error)
}

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

type ConstraintTableDef Uses

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

ConstraintTableDef represents a constraint definition within a CREATE TABLE statement.

type ContainsWindowVisitor Uses

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

ContainsWindowVisitor checks if walked expressions contain window functions.

func (*ContainsWindowVisitor) ContainsWindowFunc Uses

func (v *ContainsWindowVisitor) ContainsWindowFunc(expr Expr) bool

ContainsWindowFunc determines if an Expr contains a window function.

func (*ContainsWindowVisitor) VisitPost Uses

func (*ContainsWindowVisitor) VisitPost(expr Expr) Expr

VisitPost satisfies the Visitor interface.

func (*ContainsWindowVisitor) VisitPre Uses

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

VisitPre satisfies the Visitor interface.

type CopyFrom Uses

type CopyFrom struct {
    Table   NormalizableTableName
    Columns UnresolvedNames
    Stdin   bool
}

CopyFrom represents a COPY FROM statement.

func (*CopyFrom) Format Uses

func (node *CopyFrom) Format(buf *bytes.Buffer, f FmtFlags)

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

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

CreateDatabase represents a CREATE DATABASE statement.

func (*CreateDatabase) Format Uses

func (node *CreateDatabase) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*CreateDatabase) StatementTag Uses

func (*CreateDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateDatabase) StatementType Uses

func (*CreateDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateDatabase) String Uses

func (n *CreateDatabase) String() string

type CreateIndex Uses

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

CreateIndex represents a CREATE INDEX statement.

func (*CreateIndex) Format Uses

func (node *CreateIndex) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*CreateIndex) StatementTag Uses

func (*CreateIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateIndex) StatementType Uses

func (*CreateIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateIndex) String Uses

func (n *CreateIndex) String() string

type CreateTable Uses

type CreateTable struct {
    IfNotExists   bool
    Table         NormalizableTableName
    Interleave    *InterleaveDef
    Defs          TableDefs
    AsSource      *Select
    AsColumnNames NameList // Only to be used in conjunction with AsSource
}

CreateTable represents a CREATE TABLE statement.

func (*CreateTable) As Uses

func (node *CreateTable) As() bool

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

func (*CreateTable) Format Uses

func (node *CreateTable) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*CreateTable) StatementTag Uses

func (n *CreateTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateTable) StatementType Uses

func (*CreateTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateTable) String Uses

func (n *CreateTable) String() string

type CreateUser Uses

type CreateUser struct {
    Name     Name
    Password *string // pointer so that empty and nil can be differentiated
}

CreateUser represents a CREATE USER statement.

func (*CreateUser) Format Uses

func (node *CreateUser) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*CreateUser) HasPassword Uses

func (node *CreateUser) HasPassword() bool

HasPassword returns if the CreateUser has a password.

func (*CreateUser) StatementTag Uses

func (*CreateUser) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateUser) StatementType Uses

func (*CreateUser) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateUser) String Uses

func (n *CreateUser) String() string

type CreateView Uses

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

CreateView represents a CREATE VIEW statement.

func (*CreateView) Format Uses

func (node *CreateView) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*CreateView) StatementTag Uses

func (*CreateView) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateView) StatementType Uses

func (*CreateView) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateView) String Uses

func (n *CreateView) String() string

type DArray Uses

type DArray struct {
    ParamTyp Type
    Array    Datums
    // HasNulls is set to true if any of the datums within the array are null.
    // This is used in the binary array serialization format.
    HasNulls bool
}

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

func AsDArray Uses

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

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

func MustBeDArray Uses

func MustBeDArray(e Expr) *DArray

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

func NewDArray Uses

func NewDArray(paramTyp Type) *DArray

NewDArray returns a DArray containing elements of the specified type.

func (*DArray) AmbiguousFormat Uses

func (*DArray) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DArray) Append Uses

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

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

func (*DArray) Compare Uses

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

Compare implements the Datum interface.

func (*DArray) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DArray) Format Uses

func (d *DArray) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DArray) IsMax Uses

func (d *DArray) IsMax() bool

IsMax implements the Datum interface.

func (*DArray) IsMin Uses

func (d *DArray) IsMin() bool

IsMin implements the Datum interface.

func (*DArray) Len Uses

func (d *DArray) Len() int

Len returns the length of the Datum array.

func (*DArray) Next Uses

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

Next implements the Datum interface.

func (*DArray) Prev Uses

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

Prev implements the Datum interface.

func (*DArray) ResolvedType Uses

func (d *DArray) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DArray) Size Uses

func (d *DArray) Size() uintptr

Size implements the Datum interface.

func (*DArray) String Uses

func (node *DArray) String() string

func (*DArray) TypeCheck Uses

func (d *DArray) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DArray) Walk Uses

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

Walk implements the Expr interface.

type DBool Uses

type DBool bool

DBool is the boolean Datum.

func GetBool Uses

func GetBool(d Datum) (DBool, error)

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

func MakeDBool Uses

func MakeDBool(d DBool) *DBool

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

func ParseDBool Uses

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

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

func (*DBool) AmbiguousFormat Uses

func (*DBool) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBool) Compare Uses

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

Compare implements the Datum interface.

func (*DBool) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DBool) Format Uses

func (d *DBool) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DBool) IsMax Uses

func (d *DBool) IsMax() bool

IsMax implements the Datum interface.

func (*DBool) IsMin Uses

func (d *DBool) IsMin() bool

IsMin implements the Datum interface.

func (*DBool) Next Uses

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

Next implements the Datum interface.

func (*DBool) Prev Uses

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

Prev implements the Datum interface.

func (*DBool) ResolvedType Uses

func (*DBool) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DBool) Size Uses

func (d *DBool) Size() uintptr

Size implements the Datum interface.

func (*DBool) String Uses

func (node *DBool) String() string

func (*DBool) TypeCheck Uses

func (d *DBool) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DBool) Walk Uses

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

Walk implements the Expr interface.

type DBytes Uses

type DBytes string

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

func NewDBytes Uses

func NewDBytes(d DBytes) *DBytes

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

func (*DBytes) AmbiguousFormat Uses

func (*DBytes) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBytes) Compare Uses

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

Compare implements the Datum interface.

func (*DBytes) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DBytes) Format Uses

func (d *DBytes) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DBytes) IsMax Uses

func (*DBytes) IsMax() bool

IsMax implements the Datum interface.

func (*DBytes) IsMin Uses

func (d *DBytes) IsMin() bool

IsMin implements the Datum interface.

func (*DBytes) Next Uses

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

Next implements the Datum interface.

func (*DBytes) Prev Uses

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

Prev implements the Datum interface.

func (*DBytes) ResolvedType Uses

func (*DBytes) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DBytes) Size Uses

func (d *DBytes) Size() uintptr

Size implements the Datum interface.

func (*DBytes) String Uses

func (node *DBytes) String() string

func (*DBytes) TypeCheck Uses

func (d *DBytes) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DBytes) Walk Uses

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

Walk implements the Expr interface.

type DCollatedString Uses

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

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

func NewDCollatedString Uses

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

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

func (*DCollatedString) AmbiguousFormat Uses

func (*DCollatedString) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DCollatedString) Compare Uses

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

Compare implements the Datum interface.

func (*DCollatedString) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DCollatedString) Format Uses

func (d *DCollatedString) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DCollatedString) IsComposite Uses

func (d *DCollatedString) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DCollatedString) IsMax Uses

func (*DCollatedString) IsMax() bool

IsMax implements the Datum interface.

func (*DCollatedString) IsMin Uses

func (d *DCollatedString) IsMin() bool

IsMin implements the Datum interface.

func (*DCollatedString) Next Uses

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

Next implements the Datum interface.

func (*DCollatedString) Prev Uses

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

Prev implements the Datum interface.

func (*DCollatedString) ResolvedType Uses

func (d *DCollatedString) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DCollatedString) Size Uses

func (d *DCollatedString) Size() uintptr

Size implements the Datum interface.

func (*DCollatedString) String Uses

func (node *DCollatedString) String() string

func (*DCollatedString) TypeCheck Uses

func (d *DCollatedString) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DCollatedString) Walk Uses

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

Walk implements the Expr interface.

type DDate Uses

type DDate int64

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

func NewDDate Uses

func NewDDate(d DDate) *DDate

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

func NewDDateFromTime Uses

func NewDDateFromTime(t time.Time, loc *time.Location) *DDate

NewDDateFromTime constructs a *DDate from a time.Time in the provided time zone.

func ParseDDate Uses

func ParseDDate(s string, loc *time.Location) (*DDate, error)

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

func (*DDate) AmbiguousFormat Uses

func (*DDate) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDate) Compare Uses

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

Compare implements the Datum interface.

func (*DDate) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DDate) Format Uses

func (d *DDate) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DDate) IsMax Uses

func (d *DDate) IsMax() bool

IsMax implements the Datum interface.

func (*DDate) IsMin Uses

func (d *DDate) IsMin() bool

IsMin implements the Datum interface.

func (*DDate) Next Uses

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

Next implements the Datum interface.

func (*DDate) Prev Uses

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

Prev implements the Datum interface.

func (*DDate) ResolvedType Uses

func (*DDate) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DDate) Size Uses

func (d *DDate) Size() uintptr

Size implements the Datum interface.

func (*DDate) String Uses

func (node *DDate) String() string

func (*DDate) TypeCheck Uses

func (d *DDate) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DDate) Walk Uses

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

Walk implements the Expr interface.

type DDecimal Uses

type DDecimal struct {
    apd.Decimal
}

DDecimal is the decimal Datum.

var DecimalOne DDecimal

DecimalOne represents the constant 1 as DECIMAL.

func ParseDDecimal Uses

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

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

func TimestampToDecimal Uses

func TimestampToDecimal(ts hlc.Timestamp) *DDecimal

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

func (*DDecimal) AmbiguousFormat Uses

func (*DDecimal) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDecimal) Compare Uses

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

Compare implements the Datum interface.

func (*DDecimal) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DDecimal) Format Uses

func (d *DDecimal) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DDecimal) IsComposite Uses

func (d *DDecimal) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DDecimal) IsMax Uses

func (*DDecimal) IsMax() bool

IsMax implements the Datum interface.

func (*DDecimal) IsMin Uses

func (*DDecimal) IsMin() bool

IsMin implements the Datum interface.

func (*DDecimal) Next Uses

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

Next implements the Datum interface.

func (*DDecimal) Prev Uses

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

Prev implements the Datum interface.

func (*DDecimal) ResolvedType Uses

func (*DDecimal) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DDecimal) SetString Uses

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

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

func (*DDecimal) Size Uses

func (d *DDecimal) Size() uintptr

Size implements the Datum interface.

func (*DDecimal) String Uses

func (node *DDecimal) String() string

func (*DDecimal) TypeCheck Uses

func (d *DDecimal) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DDecimal) Walk Uses

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

Walk implements the Expr interface.

type DFloat Uses

type DFloat float64

DFloat is the float Datum.

func NewDFloat Uses

func NewDFloat(d DFloat) *DFloat

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

func ParseDFloat Uses

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

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

func (*DFloat) AmbiguousFormat Uses

func (*DFloat) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DFloat) Compare Uses

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

Compare implements the Datum interface.

func (*DFloat) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DFloat) Format Uses

func (d *DFloat) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DFloat) IsComposite Uses

func (d *DFloat) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DFloat) IsMax Uses

func (d *DFloat) IsMax() bool

IsMax implements the Datum interface.

func (*DFloat) IsMin Uses

func (d *DFloat) IsMin() bool

IsMin implements the Datum interface.

func (*DFloat) Next Uses

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

Next implements the Datum interface.

func (*DFloat) Prev Uses

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

Prev implements the Datum interface.

func (*DFloat) ResolvedType Uses

func (*DFloat) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DFloat) Size Uses

func (d *DFloat) Size() uintptr

Size implements the Datum interface.

func (*DFloat) String Uses

func (node *DFloat) String() string

func (*DFloat) TypeCheck Uses

func (d *DFloat) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DFloat) Walk Uses

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

Walk implements the Expr interface.

type DInt Uses

type DInt int64

DInt is the int Datum.

func AsDInt Uses

func AsDInt(e Expr) (DInt, bool)

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

func GenerateUniqueInt Uses

func GenerateUniqueInt(nodeID roachpb.NodeID) DInt

GenerateUniqueInt creates a unique int composed of the current time at a 10-microsecond granularity and the node-id. The node-id is stored in the lower 15 bits of the returned value and the timestamp is stored in the upper 48 bits. The top-bit is left empty so that negative values are not returned. The 48-bit timestamp field provides for 89 years of timestamps. We use a custom epoch (Jan 1, 2015) in order to utilize the entire timestamp range.

Note that GenerateUniqueInt() imposes a limit on node IDs while generateUniqueBytes() does not.

TODO(pmattis): Do we have to worry about persisting the milliseconds value periodically to avoid the clock ever going backwards (e.g. due to NTP adjustment)?

func MustBeDInt Uses

func MustBeDInt(e Expr) DInt

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

func NewDInt Uses

func NewDInt(d DInt) *DInt

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

func ParseDInt Uses

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

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

func (*DInt) AmbiguousFormat Uses

func (*DInt) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInt) Compare Uses

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

Compare implements the Datum interface.

func (*DInt) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DInt) Format Uses

func (d *DInt) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DInt) IsMax Uses

func (d *DInt) IsMax() bool

IsMax implements the Datum interface.

func (*DInt) IsMin Uses

func (d *DInt) IsMin() bool

IsMin implements the Datum interface.

func (*DInt) Next Uses

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

Next implements the Datum interface.

func (*DInt) Prev Uses

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

Prev implements the Datum interface.

func (*DInt) ResolvedType Uses

func (*DInt) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DInt) Size Uses

func (d *DInt) Size() uintptr

Size implements the Datum interface.

func (*DInt) String Uses

func (node *DInt) String() string

func (*DInt) TypeCheck Uses

func (d *DInt) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DInt) Walk Uses

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

Walk implements the Expr interface.

type DInterval Uses

type DInterval struct {
    duration.Duration
}

DInterval is the interval Datum.

func ParseDInterval Uses

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

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

func ParseDIntervalWithField Uses

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

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

func (*DInterval) AmbiguousFormat Uses

func (*DInterval) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInterval) Compare Uses

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

Compare implements the Datum interface.

func (*DInterval) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DInterval) Format Uses

func (d *DInterval) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DInterval) IsMax Uses

func (d *DInterval) IsMax() bool

IsMax implements the Datum interface.

func (*DInterval) IsMin Uses

func (d *DInterval) IsMin() bool

IsMin implements the Datum interface.

func (*DInterval) Next Uses

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

Next implements the Datum interface.

func (*DInterval) Prev Uses

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

Prev implements the Datum interface.

func (*DInterval) ResolvedType Uses

func (*DInterval) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DInterval) Size Uses

func (d *DInterval) Size() uintptr

Size implements the Datum interface.

func (*DInterval) String Uses

func (node *DInterval) String() string

func (*DInterval) TypeCheck Uses

func (d *DInterval) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DInterval) ValueAsString Uses

func (d *DInterval) ValueAsString() string

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

func (*DInterval) Walk Uses

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

Walk implements the Expr interface.

type DOid Uses

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

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

func MakeDOid Uses

func MakeDOid(d DInt) DOid

MakeDOid is a helper routine to create a DOid initialized from a DInt.

func NewDOid Uses

func NewDOid(d DInt) *DOid

NewDOid is a helper routine to create a *DOid initialized from a DInt.

func (*DOid) AmbiguousFormat Uses

func (*DOid) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DOid) AsRegProc Uses

func (d *DOid) AsRegProc(name string) *DOid

AsRegProc changes the input DOid into a regproc with the given name and returns it.

func (*DOid) Compare Uses

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

Compare implements the Datum interface.

func (*DOid) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DOid) Format Uses

func (d *DOid) Format(buf *bytes.Buffer, flags FmtFlags)

Format implements the Datum interface.

func (*DOid) IsMax Uses

func (d *DOid) IsMax() bool

IsMax implements the Datum interface.

func (*DOid) IsMin Uses

func (d *DOid) IsMin() bool

IsMin implements the Datum interface.

func (*DOid) Next Uses

func (d *DOid) Next() (Datum, bool)

Next implements the Datum interface.

func (*DOid) Prev Uses

func (d *DOid) Prev() (Datum, bool)

Prev implements the Datum interface.

func (*DOid) ResolvedType Uses

func (d *DOid) ResolvedType() Type

ResolvedType implements the Datum interface.

func (*DOid) Size Uses

func (d *DOid) Size() uintptr

Size implements the Datum interface.

func (*DOid) String Uses

func (node *DOid) String() string

func (*DOid) TypeCheck Uses

func (d *DOid) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DOid) Walk Uses

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

Walk implements the Expr interface.

type DOidWrapper Uses

type DOidWrapper struct {
    Wrapped Datum
    Oid     oid.Oid
}

DOidWrapper is a Datum implementation which is a wrapper around a Datum, allowing custom Oid values to be attached to the Datum and its Type (see tOidWrapper). The reason the Datum type was introduced was to permit the introduction of Datum types with new Object IDs while maintaining identical behavior to current Datum types. Specifically, it obviates the need to: - define a new parser.Datum type. - define a new parser.Type type. - support operations and functions for the new Type. - support mixed-type operations between the new Type and the old Type.

Instead, DOidWrapper allows a standard Datum to be wrapped with a new Oid. This approach provides two major advantages: - performance of the existing Datum types are not affected because they

do not need to have custom oid.Oids added to their structure.

- the introduction of new Datum aliases is straightforward and does not require

additions to typing rules or type-dependent evaluation behavior.

Types that currently benefit from DOidWrapper are: - DName => DOidWrapper(*DString, oid.T_name)

func (*DOidWrapper) AmbiguousFormat Uses

func (d *DOidWrapper) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DOidWrapper) Compare Uses

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

Compare implements the Datum interface.

func (*DOidWrapper) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DOidWrapper) Format Uses

func (d *DOidWrapper) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DOidWrapper) IsMax Uses

func (d *DOidWrapper) IsMax() bool

IsMax implements the Datum interface.

func (*DOidWrapper) IsMin Uses

func (d *DOidWrapper) IsMin() bool

IsMin implements the Datum interface.

func (*DOidWrapper) Next Uses

func (d *DOidWrapper) Next() (Datum, bool)

Next implements the Datum interface.

func (*DOidWrapper) Prev Uses

func (d *DOidWrapper) Prev() (Datum, bool)

Prev implements the Datum interface.

func (*DOidWrapper) ResolvedType Uses

func (d *DOidWrapper) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DOidWrapper) Size Uses

func (d *DOidWrapper) Size() uintptr

Size implements the Datum interface.

func (*DOidWrapper) String Uses

func (node *DOidWrapper) String() string

func (*DOidWrapper) TypeCheck Uses

func (d *DOidWrapper) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DOidWrapper) Walk Uses

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

Walk implements the Expr interface.

type DString Uses

type DString string

DString is the string Datum.

func AsDString Uses

func AsDString(e Expr) (DString, bool)

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

func MustBeDString Uses

func MustBeDString(e Expr) DString

MustBeDString attempts to retrieve a DString from an Expr, panicking if the assertion fails.

func NewDString Uses

func NewDString(d string) *DString

NewDString is a helper routine to create a *DString initialized from its argument.

func (*DString) AmbiguousFormat Uses

func (*DString) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DString) Compare Uses

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

Compare implements the Datum interface.

func (*DString) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DString) Format Uses

func (d *DString) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DString) IsMax Uses

func (*DString) IsMax() bool

IsMax implements the Datum interface.

func (*DString) IsMin Uses

func (d *DString) IsMin() bool

IsMin implements the Datum interface.

func (*DString) Next Uses

func (d *DString) Next() (Datum, bool)

Next implements the Datum interface.

func (*DString) Prev Uses

func (d *DString) Prev() (Datum, bool)

Prev implements the Datum interface.

func (*DString) ResolvedType Uses

func (*DString) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DString) Size Uses

func (d *DString) Size() uintptr

Size implements the Datum interface.

func (*DString) String Uses

func (node *DString) String() string

func (*DString) TypeCheck Uses

func (d *DString) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DString) Walk Uses

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

Walk implements the Expr interface.

type DTable Uses

type DTable struct {
    ValueGenerator
}

DTable is the table Datum. It is used for datums that hold an entire table generator. See the comments in generator_builtins.go for details.

func (*DTable) AmbiguousFormat Uses

func (*DTable) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTable) Compare Uses

func (t *DTable) Compare(ctx *EvalContext, other Datum) int

Compare implements the Datum interface.

func (*DTable) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DTable) Format Uses

func (t *DTable) Format(buf *bytes.Buffer, _ FmtFlags)

Format implements the NodeFormatter interface.

func (*DTable) IsMax Uses

func (*DTable) IsMax() bool

IsMax implements the Datum interface.

func (*DTable) IsMin Uses

func (*DTable) IsMin() bool

IsMin implements the Datum interface.

func (*DTable) Next Uses

func (*DTable) Next() (Datum, bool)

Next implements the Datum interface.

func (*DTable) Prev Uses

func (*DTable) Prev() (Datum, bool)

Prev implements the Datum interface.

func (*DTable) ResolvedType Uses

func (t *DTable) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTable) Size Uses

func (*DTable) Size() uintptr

Size implements the Datum interface.

func (*DTable) String Uses

func (node *DTable) String() string

func (*DTable) TypeCheck Uses

func (d *DTable) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DTable) Walk Uses

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

Walk implements the Expr interface.

type DTimestamp Uses

type DTimestamp struct {
    time.Time
}

DTimestamp is the timestamp Datum.

func MakeDTimestamp Uses

func MakeDTimestamp(t time.Time, precision time.Duration) *DTimestamp

MakeDTimestamp creates a DTimestamp with specified precision.

func ParseDTimestamp Uses

func ParseDTimestamp(s string, precision time.Duration) (*DTimestamp, error)

ParseDTimestamp parses and returns the *DTimestamp Datum value represented by the provided string in UTC, or an error if parsing is unsuccessful.

func (*DTimestamp) AmbiguousFormat Uses

func (*DTimestamp) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTimestamp) Compare Uses

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

Compare implements the Datum interface.

func (*DTimestamp) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DTimestamp) Format Uses

func (d *DTimestamp) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DTimestamp) IsMax Uses

func (d *DTimestamp) IsMax() bool

IsMax implements the Datum interface.

func (*DTimestamp) IsMin Uses

func (d *DTimestamp) IsMin() bool

IsMin implements the Datum interface.

func (*DTimestamp) Next Uses

func (d *DTimestamp) Next() (Datum, bool)

Next implements the Datum interface.

func (*DTimestamp) Prev Uses

func (d *DTimestamp) Prev() (Datum, bool)

Prev implements the Datum interface.

func (*DTimestamp) ResolvedType Uses

func (*DTimestamp) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTimestamp) Size Uses

func (d *DTimestamp) Size() uintptr

Size implements the Datum interface.

func (*DTimestamp) String Uses

func (node *DTimestamp) String() string

func (*DTimestamp) TypeCheck Uses

func (d *DTimestamp) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DTimestamp) Walk Uses

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

Walk implements the Expr interface.

type DTimestampTZ Uses

type DTimestampTZ struct {
    time.Time
}

DTimestampTZ is the timestamp Datum that is rendered with session offset.

func MakeDTimestampTZ Uses

func MakeDTimestampTZ(t time.Time, precision time.Duration) *DTimestampTZ

MakeDTimestampTZ creates a DTimestampTZ with specified precision.

func MakeDTimestampTZFromDate Uses

func MakeDTimestampTZFromDate(loc *time.Location, d *DDate) *DTimestampTZ

MakeDTimestampTZFromDate creates a DTimestampTZ from a DDate.

func ParseDTimestampTZ Uses

func ParseDTimestampTZ(
    s string, loc *time.Location, precision time.Duration,
) (*DTimestampTZ, error)

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

func (*DTimestampTZ) AmbiguousFormat Uses

func (*DTimestampTZ) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTimestampTZ) Compare Uses

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

Compare implements the Datum interface.

func (*DTimestampTZ) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DTimestampTZ) Format Uses

func (d *DTimestampTZ) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DTimestampTZ) IsMax Uses

func (d *DTimestampTZ) IsMax() bool

IsMax implements the Datum interface.

func (*DTimestampTZ) IsMin Uses

func (d *DTimestampTZ) IsMin() bool

IsMin implements the Datum interface.

func (*DTimestampTZ) Next Uses

func (d *DTimestampTZ) Next() (Datum, bool)

Next implements the Datum interface.

func (*DTimestampTZ) Prev Uses

func (d *DTimestampTZ) Prev() (Datum, bool)

Prev implements the Datum interface.

func (*DTimestampTZ) ResolvedType Uses

func (*DTimestampTZ) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTimestampTZ) Size Uses

func (d *DTimestampTZ) Size() uintptr

Size implements the Datum interface.

func (*DTimestampTZ) String Uses

func (node *DTimestampTZ) String() string

func (*DTimestampTZ) TypeCheck Uses

func (d *DTimestampTZ) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DTimestampTZ) Walk Uses

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

Walk implements the Expr interface.

type DTuple Uses

type DTuple struct {
    D   Datums

    Sorted bool
}

DTuple is the tuple Datum.

func NewDTuple Uses

func NewDTuple(d ...Datum) *DTuple

NewDTuple creates a *DTuple with the provided datums. When creating a new DTuple with Datums that are known to be sorted in ascending order, chain this call with DTuple.SetSorted.

func NewDTupleWithCap Uses

func NewDTupleWithCap(c int) *DTuple

NewDTupleWithCap creates a *DTuple with the provided capacity.

func NewDTupleWithLen Uses

func NewDTupleWithLen(l int) *DTuple

NewDTupleWithLen creates a *DTuple with the provided length.

func (*DTuple) AmbiguousFormat Uses

func (*DTuple) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTuple) AssertSorted Uses

func (d *DTuple) AssertSorted()

AssertSorted asserts that the DTuple is sorted.

func (*DTuple) Compare Uses

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

Compare implements the Datum interface.

func (*DTuple) Eval Uses

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

Eval implements the TypedExpr interface.

func (*DTuple) Format Uses

func (d *DTuple) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DTuple) IsMax Uses

func (d *DTuple) IsMax() bool

IsMax implements the Datum interface.

func (*DTuple) IsMin Uses

func (d *DTuple) IsMin() bool

IsMin implements the Datum interface.

func (*DTuple) Next Uses

func (d *DTuple) Next() (Datum, bool)

Next implements the Datum interface.

func (*DTuple) Normalize Uses

func (d *DTuple) Normalize(ctx *EvalContext)

Normalize sorts and uniques the datum tuple.

func (*DTuple) Prev Uses

func (d *DTuple) Prev() (Datum, bool)

Prev implements the Datum interface.

func (*DTuple) ResolvedType Uses

func (d *DTuple) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTuple) SearchSorted Uses

func (d *DTuple) SearchSorted(ctx *EvalContext, target Datum) (int, bool)

SearchSorted searches the tuple for the target Datum, returning an int with the same contract as sort.Search and a boolean flag signifying whether the datum was found. It assumes that the DTuple is sorted and panics if it is not.

func (*DTuple) SetSorted Uses

func (d *DTuple) SetSorted() *DTuple

SetSorted sets the sorted flag on the DTuple. This should be used when a DTuple is known to be sorted based on the datums added to it.

func (*DTuple) Size Uses

func (d *DTuple) Size() uintptr

Size implements the Datum interface.

func (*DTuple) SortedDifference Uses

func (d *DTuple) SortedDifference(ctx *EvalContext, other *DTuple) *DTuple

SortedDifference finds the elements of d which are not in other, assuming that d and other are already sorted.

func (*DTuple) String Uses

func (node *DTuple) String() string

func (*DTuple) TypeCheck Uses

func (d *DTuple) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)

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

func (*DTuple) Walk Uses

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

Walk implements the Expr interface.

type DateColType Uses

type DateColType struct {
}

DateColType represents a DATE type.

func (*DateColType) Format Uses

func (node *DateColType) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DateColType) String Uses

func (node *DateColType) String() string

type Datum Uses

type Datum interface {
    TypedExpr

    // AmbiguousFormat indicates whether the result of formatting this Datum can
    // be interpreted into more than one type. Used with
    // fmtFlags.disambiguateDatumTypes.
    AmbiguousFormat() bool

    // Compare returns -1 if the receiver is less than other, 0 if receiver is
    // equal to other and +1 if receiver is greater than other.
    Compare(ctx *EvalContext, other Datum) int

    // Prev returns the previous datum and true, if one exists, or nil
    // and false.  The previous datum satisfied the following
    // definition: if the receiver is "b" and the returned datum is "a",
    // then "a < b" and no other datum will compare such that "a < c <
    // b".
    // The return value is undefined if `IsMin()` returns true.
    Prev() (Datum, bool)

    // IsMin returns true if the datum is equal to the minimum value the datum
    // type can hold.
    IsMin() bool

    // Next returns the next datum and true, if one exists, or nil
    // and false otherwise. The next datum satisfied the following
    // definition: if the receiver is "a" and the returned datum is "b",
    // then "a < b" and no other datum will compare such that "a < c <
    // b".
    // The return value is undefined if `IsMax()` returns true.
    Next() (Datum, bool)

    // IsMax returns true if the datum is equal to the maximum value the datum
    // type can hold.
    IsMax() bool

    // Size returns a lower bound on the total size of the receiver in bytes,
    // including memory that is pointed at (even if shared between Datum
    // instances) but excluding allocation overhead.
    //
    // It holds for every Datum d that d.Size() >= d.ResolvedType().Size().
    Size() uintptr
    // contains filtered or unexported methods
}

Datum represents a SQL value.

func NewDIntVectorFromDArray Uses

func NewDIntVectorFromDArray(d *DArray) Datum

NewDIntVectorFromDArray is a helper routine to create a *DIntVector (implemented as a *DOidWrapper) initialized from an existing *DArray.

func NewDName Uses

func NewDName(d string) Datum

NewDName is a helper routine to create a *DName (implemented as a *DOidWrapper) initialized from a string.

func NewDNameFromDString Uses

func NewDNameFromDString(d *DString) Datum

NewDNameFromDString is a helper routine to create a *DName (implemented as a *DOidWrapper) initialized from an existing *DString.

func UnwrapDatum Uses

func UnwrapDatum(d Datum) Datum

UnwrapDatum returns the base Datum type for a provided datum, stripping an *DOidWrapper if present. This is useful for cases like type switches, where type aliases should be ignored.

type Datums Uses

type Datums []Datum

Datums is a slice of Datum values.

func (Datums) Format Uses

func (d Datums) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (Datums) Len Uses

func (d Datums) Len() int

Len returns the number of Datum values.

func (Datums) Reverse Uses

func (d Datums) Reverse()

Reverse reverses the order of the Datum values.

func (*Datums) String Uses

func (node *Datums) String() string

type Deallocate Uses

type Deallocate struct {
    Name Name // empty for ALL
}

Deallocate represents a DEALLOCATE statement.

func (*Deallocate) Format Uses

func (node *Deallocate) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*Deallocate) StatementTag Uses

func (n *Deallocate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Deallocate) StatementType Uses

func (*Deallocate) StatementType() StatementType

StatementType implements the Statement interface.

func (*Deallocate) String Uses

func (n *Deallocate) String() string

type DecimalColType Uses

type DecimalColType struct {
    Name  string
    Prec  int
    Scale int
}

DecimalColType represents a DECIMAL or NUMERIC type.

func (*DecimalColType) Format Uses

func (node *DecimalColType) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DecimalColType) String Uses

func (node *DecimalColType) String() string

type DefaultVal Uses

type DefaultVal struct{}

DefaultVal represents the DEFAULT expression.

func (DefaultVal) Eval Uses

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

Eval implements the TypedExpr interface.

func (DefaultVal) Format Uses

func (node DefaultVal) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (DefaultVal) ResolvedType Uses

func (DefaultVal) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (DefaultVal) String Uses

func (node DefaultVal) String() string

func (DefaultVal) TypeCheck Uses

func (expr DefaultVal) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (DefaultVal) Walk Uses

func (expr DefaultVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type Delete Uses

type Delete struct {
    Table     TableExpr
    Where     *Where
    Returning ReturningClause
}

Delete represents a DELETE statement.

func (*Delete) CopyNode Uses

func (stmt *Delete) CopyNode() *Delete

CopyNode makes a copy of this Statement without recursing in any child Statements.

func (*Delete) Format Uses

func (node *Delete) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*Delete) StatementTag Uses

func (*Delete) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Delete) StatementType Uses

func (n *Delete) StatementType() StatementType

StatementType implements the Statement interface.

func (*Delete) String Uses

func (n *Delete) String() string

func (*Delete) WalkStmt Uses

func (stmt *Delete) WalkStmt(v Visitor) Statement

WalkStmt is part of the WalkableStmt interface.

type Direction Uses

type Direction int

Direction for ordering results.

const (
    DefaultDirection Direction = iota
    Ascending
    Descending
)

Direction values.

func (Direction) String Uses

func (d Direction) String() string

type DropBehavior Uses

type DropBehavior int

DropBehavior represents options for dropping schema elements.

const (
    DropDefault DropBehavior = iota
    DropRestrict
    DropCascade
)

DropBehavior values.

func (DropBehavior) String Uses

func (d DropBehavior) String() string

type DropDatabase Uses

type DropDatabase struct {
    Name     Name
    IfExists bool
}

DropDatabase represents a DROP DATABASE statement.

func (*DropDatabase) Format Uses

func (node *DropDatabase) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DropDatabase) StatementTag Uses

func (*DropDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropDatabase) StatementType Uses

func (*DropDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropDatabase) String Uses

func (n *DropDatabase) String() string

type DropIndex Uses

type DropIndex struct {
    IndexList    TableNameWithIndexList
    IfExists     bool
    DropBehavior DropBehavior
}

DropIndex represents a DROP INDEX statement.

func (*DropIndex) Format Uses

func (node *DropIndex) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DropIndex) StatementTag Uses

func (*DropIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropIndex) StatementType Uses

func (*DropIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropIndex) String Uses

func (n *DropIndex) String() string

type DropTable Uses

type DropTable struct {
    Names        TableNameReferences
    IfExists     bool
    DropBehavior DropBehavior
}

DropTable represents a DROP TABLE statement.

func (*DropTable) Format Uses

func (node *DropTable) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DropTable) StatementTag Uses

func (*DropTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropTable) StatementType Uses

func (*DropTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropTable) String Uses

func (n *DropTable) String() string

type DropView Uses

type DropView struct {
    Names        TableNameReferences
    IfExists     bool
    DropBehavior DropBehavior
}

DropView represents a DROP VIEW statement.

func (*DropView) Format Uses

func (node *DropView) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*DropView) StatementTag Uses

func (*DropView) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropView) StatementType Uses

func (*DropView) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropView) String Uses

func (n *DropView) String() string

type EvalContext Uses

type EvalContext struct {
    NodeID roachpb.NodeID

    // Location references the *Location on the current Session.
    Location **time.Location
    // Database is the database in the current Session.
    Database string
    // SearchPath is the search path for databases used when encountering an
    // unqualified table name. Names in the search path are normalized already.
    // This must not be modified (this is shared from the session).
    SearchPath SearchPath
    // Ctx represents the context in which the expression is evaluated. This will
    // point to the Session's context container.
    // NOTE: seems a bit lazy to hold a pointer to the session's context here,
    // instead of making sure the right context is explicitly set before the
    // EvalContext is used. But there's already precedent with the Location field,
    // and also at the time of writing, EvalContexts are initialized with the
    // planner and not mutated.
    Ctx contextHolder

    Planner EvalPlanner

    ReCache *RegexpCache

    // TODO(mjibson): remove prepareOnly in favor of a 2-step prepare-exec solution
    // that is also able to save the plan to skip work during the exec step.
    PrepareOnly bool

    // SkipNormalize indicates whether expressions should be normalized
    // (false) or not (true).  It is set to true conditionally by
    // EXPLAIN(TYPES[, NORMALIZE]).
    SkipNormalize bool

    Mon *mon.MemoryMonitor
    // contains filtered or unexported fields
}

EvalContext defines the context in which to evaluate an expression, allowing the retrieval of state such as the node ID or statement start time.

func (*EvalContext) GetClusterTimestamp Uses

func (ctx *EvalContext) GetClusterTimestamp() *DDecimal

GetClusterTimestamp retrieves the current cluster timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.

func (*EvalContext) GetLocation Uses

func (ctx *EvalContext) GetLocation() *time.Location

GetLocation returns the session timezone.

func (*EvalContext) GetStmtTimestamp Uses

func (ctx *EvalContext) GetStmtTimestamp() time.Time

GetStmtTimestamp retrieves the current statement timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.

func (*EvalContext) GetTxnTimestamp Uses

func (ctx *EvalContext) GetTxnTimestamp(precision time.Duration) *DTimestampTZ

GetTxnTimestamp retrieves the current transaction timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.

func (*EvalContext) GetTxnTimestampNoZone Uses

func (ctx *EvalContext) GetTxnTimestampNoZone(precision time.Duration) *DTimestamp

GetTxnTimestampNoZone retrieves the current transaction timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.

func (*EvalContext) NormalizeExpr Uses

func (ctx *EvalContext) NormalizeExpr(typedExpr TypedExpr) (TypedExpr, error)

NormalizeExpr normalizes a typed expression, simplifying where possible, but guaranteeing that the result of evaluating the expression is unchanged and that resulting expression tree is still well-typed. Example normalizations:

(a)                   -> a
a = 1 + 1             -> a = 2
a + 1 = 2             -> a = 1
a BETWEEN b AND c     -> (a >= b) AND (a <= c)
a NOT BETWEEN b AND c -> (a < b) OR (a > c)

func (*EvalContext) SetClusterTimestamp Uses

func (ctx *EvalContext) SetClusterTimestamp(ts hlc.Timestamp)

SetClusterTimestamp sets the corresponding timestamp in the EvalContext.

func (*EvalContext) SetStmtTimestamp Uses

func (ctx *EvalContext) SetStmtTimestamp(ts time.Time)

SetStmtTimestamp sets the corresponding timestamp in the EvalContext.

func (*EvalContext) SetTxnTimestamp Uses

func (ctx *EvalContext) SetTxnTimestamp(ts time.Time)

SetTxnTimestamp sets the corresponding timestamp in the EvalContext.

type EvalPlanner Uses

type EvalPlanner interface {
    // QueryRow executes a SQL query string where exactly 1 result row is
    // expected and returns that row.
    QueryRow(ctx context.Context, sql string, args ...interface{}) (Datums, error)

    // QualifyWithDatabase resolves a possibly unqualified table name into a
    // table name that is qualified by database.
    QualifyWithDatabase(ctx context.Context, t *NormalizableTableName) (*TableName, error)
}

EvalPlanner is a limited planner that can be used from EvalContext.

type Execute Uses

type Execute struct {
    Name   Name
    Params Exprs
}

Execute represents an EXECUTE statement.

func (*Execute) Format Uses

func (node *Execute) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*Execute) StatementTag Uses

func (*Execute) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Execute) StatementType Uses

func (*Execute) StatementType() StatementType

StatementType implements the Statement interface.

func (*Execute) String Uses

func (n *Execute) String() string

type ExistsExpr Uses

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

ExistsExpr represents an EXISTS expression.

func (*ExistsExpr) Eval Uses

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

Eval implements the TypedExpr interface.

func (*ExistsExpr) Format Uses

func (node *ExistsExpr) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (ExistsExpr) ResolvedType Uses

func (ta ExistsExpr) ResolvedType() Type

func (*ExistsExpr) String Uses

func (node *ExistsExpr) String() string

func (*ExistsExpr) TypeCheck Uses

func (expr *ExistsExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ExistsExpr) Walk Uses

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

Walk implements the Expr interface.

type Explain Uses

type Explain struct {
    // Options defines how EXPLAIN should operate (VERBOSE, METADATA,
    // etc.) Which options are valid depends on the explain mode. See
    // sql/explain.go for details.
    Options []string

    // Statement is the statement being EXPLAINed.
    Statement Statement

    // Enclosed is set to true if the EXPLAIN syntax was used as a data
    // source, and thus enclosed in square brackets.
    Enclosed bool
}

Explain represents an EXPLAIN statement.

func (*Explain) CopyNode Uses

func (stmt *Explain) CopyNode() *Explain

CopyNode makes a copy of this Statement without recursing in any child Statements.

func (*Explain) Format Uses

func (node *Explain) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*Explain) StatementTag Uses

func (*Explain) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Explain) StatementType Uses

func (*Explain) StatementType() StatementType

StatementType implements the Statement interface.

func (*Explain) String Uses

func (n *Explain) String() string

func (*Explain) WalkStmt Uses

func (stmt *Explain) WalkStmt(v Visitor) Statement

WalkStmt is part of the WalkableStmt interface.

type Expr Uses

type Expr interface {
    fmt.Stringer
    NodeFormatter
    // Walk recursively walks all children using WalkExpr. If any children are changed, it returns a
    // copy of this node updated to point to the new children. Otherwise the receiver is returned.
    // For childless (leaf) Exprs, its implementation is empty.
    Walk(Visitor) Expr
    // TypeCheck transforms the Expr into a well-typed TypedExpr, which further permits
    // evaluation and type introspection, or an error if the expression cannot be well-typed.
    // When type checking is complete, if no error was reported, the expression and all
    // sub-expressions will be guaranteed to be well-typed, meaning that the method effectively
    // maps the Expr tree into a TypedExpr tree.
    //
    // The ctx parameter defines the context in which to perform type checking.
    // The desired parameter hints the desired type that the method's caller wants from
    // the resulting TypedExpr. It is not valid to call TypeCheck with a nil desired
    // type. Instead, call it with wildcard type TypeAny if no specific type is
    // desired. This restriction is also true of most methods and functions related
    // to type checking.
    TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
}

Expr represents an expression.

func ParseExpr Uses

func ParseExpr(sql string) (Expr, error)

ParseExpr is a short-hand for parseExprs([]string{sql})

func SimpleVisit Uses

func SimpleVisit(expr Expr, preFn SimpleVisitFn) (Expr, error)

SimpleVisit is a convenience wrapper for visitors that only have VisitPre code and don't return any results except an error. The given function is called in VisitPre for every node. The visitor stops as soon as an error is returned.

func StripParens Uses

func StripParens(expr Expr) Expr

StripParens strips any parentheses surrounding an expression and returns the inner expression. For instance:

 1   -> 1
(1)  -> 1

((1)) -> 1

func WalkExpr Uses

func WalkExpr(v Visitor, expr Expr) (newExpr Expr, changed bool)

WalkExpr traverses the nodes in an expression.

NOTE: Do not count on the WalkStmt/WalkExpr machinery to visit all expressions contained in a query. Only a sub-set of all expressions are found by WalkStmt and subsequently traversed. See the comment below on WalkStmt for details.

type Exprs Uses

type Exprs []Expr

Exprs represents a list of value expressions. It's not a valid expression because it's not parenthesized.

func ParseExprs Uses

func ParseExprs(sql []string) (Exprs, error)

ParseExprs is a short-hand for parseExprs(sql)

func (Exprs) Format Uses

func (node Exprs) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (Exprs) String Uses

func (node Exprs) String() string

type FamilyTableDef Uses

type FamilyTableDef struct {
    Name    Name
    Columns NameList
}

FamilyTableDef represents a family definition within a CREATE TABLE statement.

func (*FamilyTableDef) Format Uses

func (node *FamilyTableDef) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type FloatColType Uses

type FloatColType struct {
    Name          string
    Prec          int
    PrecSpecified bool // true if the value of Prec is not the default
}

FloatColType represents a REAL, DOUBLE or FLOAT type.

func NewFloatColType Uses

func NewFloatColType(prec int, precSpecified bool) *FloatColType

NewFloatColType creates a type representing a FLOAT, optionally with a precision.

func (*FloatColType) Format Uses

func (node *FloatColType) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*FloatColType) String Uses

func (node *FloatColType) String() string

type FmtFlags Uses

type FmtFlags *fmtFlags

FmtFlags enables conditional formatting in the pretty-printer.

var FmtAnonymize FmtFlags = &fmtFlags{anonymize: true}

FmtAnonymize instructs the pretty-printer to remove any name but function names. TODO(knz): temporary until a better solution is found for #13968

var FmtBareStrings FmtFlags = &fmtFlags{bareStrings: true}

FmtBareStrings instructs the pretty-printer to print strings without wrapping quotes, if possible.

var FmtHideConstants FmtFlags = &fmtFlags{hideConstants: true}

FmtHideConstants instructs the pretty-printer to produce a representation that does not disclose query-specific data.

var FmtParsable FmtFlags = &fmtFlags{disambiguateDatumTypes: true}

FmtParsable instructs the pretty-printer to produce a representation that can be parsed into an equivalent expression (useful for serialization of expressions).

var FmtShowTypes FmtFlags = &fmtFlags{showTypes: true}

FmtShowTypes instructs the pretty-printer to annotate expressions with their resolved types.

var FmtSimple FmtFlags = &fmtFlags{}

FmtSimple instructs the pretty-printer to produce a straightforward representation.

var FmtSymbolicVars FmtFlags = &fmtFlags{symbolicVars: true}

FmtSymbolicVars instructs the pretty-printer to print indexedVars using symbolic notation, to disambiguate columns.

func FmtExpr Uses

func FmtExpr(base FmtFlags, showTypes bool, symbolicVars bool, showTableAliases bool) FmtFlags

FmtExpr returns FmtFlags that indicate how the pretty-printer should format expressions.

func FmtIndexedVarFormat Uses

func FmtIndexedVarFormat(
    base FmtFlags, fn func(buf *bytes.Buffer, f FmtFlags, c IndexedVarContainer, idx int),
) FmtFlags

FmtIndexedVarFormat returns FmtFlags that customizes the printing of IndexedVars using the provided function.

func FmtReformatTableNames Uses

func FmtReformatTableNames(
    base FmtFlags, fn func(*NormalizableTableName, *bytes.Buffer, FmtFlags),
) FmtFlags

FmtReformatTableNames returns FmtFlags that instructs the pretty-printer to substitute the printing of table names using the provided function.

func FmtStarDatumFormat Uses

func FmtStarDatumFormat(base FmtFlags, fn func(buf *bytes.Buffer, f FmtFlags)) FmtFlags

FmtStarDatumFormat returns FmtFlags that customizes the printing of StarDatums using the provided function.

type ForeignKeyConstraintTableDef Uses

type ForeignKeyConstraintTableDef struct {
    Name     Name
    Table    NormalizableTableName
    FromCols NameList
    ToCols   NameList
}

ForeignKeyConstraintTableDef represents a FOREIGN KEY constraint in the AST.

func (*ForeignKeyConstraintTableDef) Format Uses

func (node *ForeignKeyConstraintTableDef) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type From Uses

type From struct {
    Tables TableExprs
    AsOf   AsOfClause
}

From represents a FROM clause.

func (*From) Format Uses

func (node *From) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type FuncExpr Uses

type FuncExpr struct {
    Func  ResolvableFunctionReference
    Type  funcType
    Exprs Exprs
    // Filter is used for filters on aggregates: SUM(k) FILTER (WHERE k > 0)
    Filter    Expr
    WindowDef *WindowDef
    // contains filtered or unexported fields
}

FuncExpr represents a function call.

func (*FuncExpr) CopyNode Uses

func (expr *FuncExpr) CopyNode() *FuncExpr

CopyNode makes a copy of this Expr without recursing in any child Exprs.

func (*FuncExpr) Eval Uses

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

Eval implements the TypedExpr interface.

func (*FuncExpr) Format Uses

func (node *FuncExpr) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*FuncExpr) GetAggregateConstructor Uses

func (node *FuncExpr) GetAggregateConstructor() func(*EvalContext) AggregateFunc

GetAggregateConstructor exposes the AggregateFunc field for use by the group node in package sql.

func (*FuncExpr) GetWindowConstructor Uses

func (node *FuncExpr) GetWindowConstructor() func(*EvalContext) WindowFunc

GetWindowConstructor returns a window function constructor if the FuncExpr is a built-in window function.

func (*FuncExpr) IsContextDependent Uses

func (node *FuncExpr) IsContextDependent() bool

IsContextDependent returns whether the function depends on data stored in the EvalContext.

func (*FuncExpr) IsImpure Uses

func (node *FuncExpr) IsImpure() bool

IsImpure returns whether the function application is impure, meaning that it potentially returns a different value when called in the same statement with the same parameters.

func (*FuncExpr) IsWindowFunctionApplication Uses

func (node *FuncExpr) IsWindowFunctionApplication() bool

IsWindowFunctionApplication returns if the function is being applied as a window function.

func (FuncExpr) ResolvedType Uses

func (ta FuncExpr) ResolvedType() Type

func (*FuncExpr) String Uses

func (node *FuncExpr) String() string

func (*FuncExpr) TypeCheck Uses

func (expr *FuncExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*FuncExpr) Walk Uses

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

Walk implements the Expr interface.

type FunctionClass Uses

type FunctionClass int

FunctionClass specifies the class of the builtin function.

const (
    // NormalClass is a standard builtin function.
    NormalClass FunctionClass = iota
    // AggregateClass is a builtin aggregate function.
    AggregateClass
    // WindowClass is a builtin window function.
    WindowClass
    // GeneratorClass is a builtin generator function.
    GeneratorClass
)

type FunctionDefinition Uses

type FunctionDefinition struct {
    // Name is the short name of the function.
    Name string
    // HasOverloadsNeedingRepeatedEvaluation is true if one or more of
    // the overload definitions has needsRepeatedEvaluation set.
    // Set e.g. for aggregate functions.
    HasOverloadsNeedingRepeatedEvaluation bool
    // Definition is the set of overloads for this function name.
    Definition []Builtin
}

FunctionDefinition implements a reference to the (possibly several) overloads for a built-in function.

func (*FunctionDefinition) Format Uses

func (fd *FunctionDefinition) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*FunctionDefinition) String Uses

func (fd *FunctionDefinition) String() string

type FunctionReference Uses

type FunctionReference interface {
    fmt.Stringer
    NodeFormatter
    // contains filtered or unexported methods
}

FunctionReference is the common interface to UnresolvedName and QualifiedFunctionName.

type Grant Uses

type Grant struct {
    Privileges privilege.List
    Targets    TargetList
    Grantees   NameList
}

Grant represents a GRANT statement.

func (*Grant) Format Uses

func (node *Grant) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*Grant) StatementTag Uses

func (*Grant) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Grant) StatementType Uses

func (*Grant) StatementType() StatementType

StatementType implements the Statement interface.

func (*Grant) String Uses

func (n *Grant) String() string

type GroupBy Uses

type GroupBy []Expr

GroupBy represents a GROUP BY clause.

func (GroupBy) Format Uses

func (node GroupBy) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type Help Uses

type Help struct {
    Name Name
}

Help represents a HELP statement.

func (*Help) Format Uses

func (node *Help) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*Help) StatementTag