Back to godoc.org

Package parser

v1.1.8
Latest Go to latest

The latest major version is .

Published: Apr 19, 2018 | License: Apache-2.0 | Module: github.com/cockroachdb/cockroach

Index

Constants

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 = 57678
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 CANCEL = 57389
const CASCADE = 57390
const CASE = 57391
const CAST = 57392
const CHAR = 57393
const CHARACTER = 57394
const CHARACTERISTICS = 57395
const CHECK = 57396
const CLUSTER = 57397
const COALESCE = 57398
const COLLATE = 57399
const COLLATION = 57400
const COLUMN = 57401
const COLUMNS = 57402
const COMMIT = 57403
const COMMITTED = 57404
const CONCAT = 57405
const CONFLICT = 57406
const CONSTRAINT = 57407
const CONSTRAINTS = 57408
const COPY = 57409
const COVERING = 57410
const CREATE = 57411
const CROSS = 57412
const CSV = 57413
const CUBE = 57414
const CURRENT = 57415
const CURRENT_CATALOG = 57416
const CURRENT_DATE = 57417
const CURRENT_ROLE = 57419
const CURRENT_SCHEMA = 57418
const CURRENT_TIME = 57420
const CURRENT_TIMESTAMP = 57421
const CURRENT_USER = 57422
const CYCLE = 57423
const DATA = 57424
const DATABASE = 57425
const DATABASES = 57426
const DATE = 57427
const DAY = 57428
const DEALLOCATE = 57432
const DEC = 57429
const DECIMAL = 57430
const DEFAULT = 57431
const DEFERRABLE = 57433
const DELETE = 57434
const DESC = 57435
const DISCARD = 57436
const DISTINCT = 57437
const DO = 57438
const DOT_DOT = 57354
const DOUBLE = 57439
const DROP = 57440
const ELSE = 57441
const ENCODING = 57442
const END = 57443
const ERROR = 57361
const ESCAPE = 57444
const EXCEPT = 57445
const EXECUTE = 57447
const EXISTS = 57446
const EXPERIMENTAL_FINGERPRINTS = 57448
const EXPLAIN = 57449
const EXTRACT = 57450
const EXTRACT_DURATION = 57451
const FALSE = 57452
const FAMILY = 57453
const FCONST = 57350
const FETCH = 57454
const FILTER = 57455
const FIRST = 57456
const FLOAT = 57457
const FLOAT4 = 57458
const FLOAT8 = 57459
const FLOORDIV = 57460
const FOLLOWING = 57461
const FOR = 57462
const FORCE_INDEX = 57463
const FOREIGN = 57464
const FROM = 57465
const FULL = 57466
const GRANT = 57467
const GRANTS = 57468
const GREATER_EQUALS = 57356
const GREATEST = 57469
const GROUP = 57470
const GROUPING = 57471
const HAVING = 57472
const HELP = 57473
const HELPTOKEN = 57681
const HIGH = 57474
const HOUR = 57475
const ICONST = 57349
const IDENT = 57346
const IF = 57478
const IFNULL = 57479
const ILIKE = 57480
const IMPORT = 57476
const IN = 57481
const INCREMENTAL = 57477
const INDEX = 57483
const INDEXES = 57484
const INITIALLY = 57485
const INNER = 57486
const INSERT = 57487
const INT = 57488
const INT2 = 57490
const INT2VECTOR = 57489
const INT4 = 57491
const INT64 = 57493
const INT8 = 57492
const INTEGER = 57494
const INTERLEAVE = 57482
const INTERSECT = 57495
const INTERVAL = 57496
const INTO = 57497
const IS = 57498
const ISOLATION = 57499
const InvalidColIdx = -1

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

const JOB = 57500
const JOBS = 57501
const JOIN = 57502
const KEY = 57503
const KEYS = 57504
const KV = 57505
const LATERAL = 57506
const LC_COLLATE = 57508
const LC_CTYPE = 57507
const LEADING = 57509
const LEAST = 57510
const LEFT = 57511
const LESS_EQUALS = 57355
const LEVEL = 57512
const LIKE = 57513
const LIMIT = 57514
const LOCAL = 57515
const LOCALTIME = 57516
const LOCALTIMESTAMP = 57517
const LOW = 57518
const LSHIFT = 57519
const MATCH = 57520
const MINUTE = 57521
const MONTH = 57522
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 = 57524
const NAMES = 57525
const NAN = 57523
const NATURAL = 57526
const NEXT = 57527
const NO = 57528
const NORMAL = 57530
const NOT = 57531
const NOTHING = 57532
const NOT_EQUALS = 57357
const NOT_LA = 57676
const NOT_REGIMATCH = 57360
const NOT_REGMATCH = 57358
const NO_INDEX_JOIN = 57529
const NULL = 57533
const NULLIF = 57534
const NULLS = 57535
const NUMERIC = 57536
const OF = 57537
const OFF = 57538
const OFFSET = 57539
const OID = 57540
const ON = 57541
const ONLY = 57542
const OPTIONS = 57543
const OR = 57544
const ORDER = 57545
const ORDINALITY = 57546
const OUT = 57547
const OUTER = 57548
const OVER = 57549
const OVERLAPS = 57550
const OVERLAY = 57551
const PARENT = 57552
const PARTIAL = 57553
const PARTITION = 57554
const PASSWORD = 57555
const PAUSE = 57556
const PLACEHOLDER = 57351
const PLACING = 57557
const PLANS = 57558
const POSITION = 57559
const POSTFIXOP = 57679
const PRECEDING = 57560
const PRECISION = 57561
const PREPARE = 57562
const PRIMARY = 57563
const PRIORITY = 57564
const QUERIES = 57565
const QUERY = 57566
const RANGE = 57567
const READ = 57568
const REAL = 57569
const RECURSIVE = 57570
const REF = 57571
const REFERENCES = 57572
const REGCLASS = 57573
const REGIMATCH = 57359
const REGNAMESPACE = 57576
const REGPROC = 57574
const REGPROCEDURE = 57575
const REGTYPE = 57577
const RELEASE = 57580
const RENAME = 57578
const REPEATABLE = 57579
const RESET = 57581
const RESTORE = 57582
const RESTRICT = 57583
const RESUME = 57584
const RETURNING = 57585
const REVOKE = 57586
const RIGHT = 57587
const ROLLBACK = 57588
const ROLLUP = 57589
const ROW = 57590
const ROWS = 57591
const RSHIFT = 57592
const RestartSavepointName string = "COCKROACH_RESTART"

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

const SAVEPOINT = 57593
const SCATTER = 57594
const SCONST = 57347
const SEARCH = 57595
const SECOND = 57596
const SELECT = 57597
const SEQUENCES = 57598
const SERIAL = 57599
const SERIALIZABLE = 57600
const SESSION = 57601
const SESSIONS = 57602
const SESSION_USER = 57603
const SET = 57604
const SETTING = 57605
const SETTINGS = 57606
const SHOW = 57607
const SIMILAR = 57608
const SIMPLE = 57609
const SMALLINT = 57610
const SMALLSERIAL = 57611
const SNAPSHOT = 57612
const SOME = 57613
const SPLIT = 57614
const SQL = 57615
const START = 57616
const STATUS = 57617
const STDIN = 57618
const STORE = 57621
const STORING = 57622
const STRICT = 57619
const STRING = 57620
const SUBSTRING = 57623
const SYMMETRIC = 57624
const SYSTEM = 57625
const TABLE = 57626
const TABLES = 57627
const TEMP = 57628
const TEMPLATE = 57629
const TEMPORARY = 57630
const TESTING_RANGES = 57631
const TESTING_RELOCATE = 57632
const TEXT = 57633
const THEN = 57634
const TIME = 57635
const TIMESTAMP = 57636
const TIMESTAMPTZ = 57637
const TO = 57638
const TRACE = 57640
const TRAILING = 57639
const TRANSACTION = 57641
const TREAT = 57642
const TRIM = 57643
const TRUE = 57644
const TRUNCATE = 57645
const TYPE = 57646
const TYPEANNOTATE = 57353
const TYPECAST = 57352
const (

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

time.Time formats.

const UMINUS = 57680
const UNBOUNDED = 57647
const UNCOMMITTED = 57648
const UNION = 57649
const UNIQUE = 57650
const UNKNOWN = 57651
const UPDATE = 57652
const UPSERT = 57653
const USE = 57654
const USER = 57655
const USERS = 57656
const USING = 57657
const UUID = 57658
const VALID = 57659
const VALIDATE = 57660
const VALUE = 57661
const VALUES = 57662
const VARCHAR = 57663
const VARIADIC = 57664
const VARYING = 57666
const VIEW = 57665
const WHEN = 57667
const WHERE = 57668
const WINDOW = 57669
const WITH = 57670
const WITHIN = 57671
const WITHOUT = 57672
const WITH_LA = 57677
const WRITE = 57673
const YEAR = 57674
const ZONE = 57675

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)
	// RoundCtx is a decimal context with high precision and RoundHalfEven
	// rounding.
	RoundCtx = func() *apd.Context {
		ctx := *HighPrecisionCtx
		ctx.Rounding = apd.RoundHalfEven
		return &ctx
	}()
)
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{}
	// TypeUUID is the type of a DUuid. Can be compared with ==.
	TypeUUID Type = tUUID{}
	// TypeTuple is the type family of a DTuple. CANNOT be compared with ==.
	TypeTuple Type = TTuple(nil)
	// TypeArray is the type family of a DArray. CANNOT be compared with ==.
	TypeArray Type = TArray{}
	// 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{}
	// 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(TArray{TypeInt}, 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,
		TypeUUID,
		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."),
	},

	"count_rows": {
		{

			Types:         ArgTypes{},
			ReturnType:    fixedReturnType(TypeInt),
			AggregateFunc: newCountRowsAggregate,
			WindowFunc: func(params []Type, evalCtx *EvalContext) WindowFunc {
				return newAggregateWindow(newCountRowsAggregate(params, evalCtx))
			},
			Info: "Calculates the number of rows.",
			// contains filtered or unexported fields
		},
	},

	"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."),
	},

	"xor_agg": {
		makeAggBuiltin(TypeBytes, TypeBytes, newBytesXorAggregate,
			"Calculates the bitwise XOR of the selected values."),
		makeAggBuiltin(TypeInt, TypeInt, newIntXorAggregate,
			"Calculates the bitwise XOR 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 AllBuiltinNames []string

AllBuiltinNames is an array containing all the built-in function names, sorted in alphabetical order. This can be used for a deterministic walk through the Builtins map.

var AllHelp = func(h map[string]HelpMessageBody) string {

	cmds := make(map[string][]string)
	for c, details := range h {
		if details.Category == "" {
			continue
		}
		cmds[details.Category] = append(cmds[details.Category], c)
	}

	// Ensure the result is deterministic.
	var categories []string
	for c, l := range cmds {
		categories = append(categories, c)
		sort.Strings(l)
	}
	sort.Strings(categories)

	// Compile the final help index.
	var buf bytes.Buffer
	w := tabwriter.NewWriter(&buf, 0, 0, 1, ' ', 0)
	for _, cat := range categories {
		fmt.Fprintf(w, "%s:\n", strings.Title(cat))
		for _, item := range cmds[cat] {
			fmt.Fprintf(w, "\t\t%s\t%s\n", item, h[item].ShortDescription)
		}
		fmt.Fprintln(w)
	}
	_ = w.Flush()
	return buf.String()
}(helpMessages)

AllHelp contains an overview of all statements with help messages. For example, displayed in the CLI shell with \h without additional parameters.

var ArrayOids = map[oid.Oid]struct{}{}

ArrayOids is a set of all oids which correspond to an array type.

var BinOps = map[BinaryOperator]binOpOverload{
	Bitand: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	Bitor: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	Bitxor: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	Plus: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeFloat,
			RightType:  TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDate,
			RightType:  TypeInt,
			ReturnType: TypeDate,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDate,
			ReturnType: TypeDate,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestamp,
			RightType:  TypeInterval,
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeTimestamp,
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestampTZ,
			RightType:  TypeInterval,
			ReturnType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeTimestampTZ,
			ReturnType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeInterval,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDate,
			RightType:  TypeInterval,
			ReturnType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeDate,
			ReturnType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
	},

	Minus: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeFloat,
			RightType:  TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDate,
			RightType:  TypeInt,
			ReturnType: TypeDate,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDate,
			RightType:  TypeDate,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestamp,
			RightType:  TypeTimestamp,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestampTZ,
			RightType:  TypeTimestampTZ,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestamp,
			RightType:  TypeTimestampTZ,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestampTZ,
			RightType:  TypeTimestamp,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestamp,
			RightType:  TypeInterval,
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestampTZ,
			RightType:  TypeInterval,
			ReturnType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDate,
			RightType:  TypeInterval,
			ReturnType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeInterval,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
	},

	Mult: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeFloat,
			RightType:  TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},

		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInterval,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeInt,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeFloat,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
	},

	Div: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeFloat,
			RightType:  TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeInt,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInterval,
			RightType:  TypeFloat,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
	},

	FloorDiv: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeFloat,
			RightType:  TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
	},

	Mod: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeFloat,
			RightType:  TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
	},

	Concat: {
		BinOp{
			LeftType:   TypeString,
			RightType:  TypeString,
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeBytes,
			RightType:  TypeBytes,
			ReturnType: TypeBytes,
			// contains filtered or unexported fields
		},
	},

	LShift: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	RShift: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	Pow: {
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeFloat,
			RightType:  TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			RightType:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
	},
}

BinOps contains the binary operations indexed by operation type.

var Builtins = map[string][]Builtin{ /* 109 elements not displayed */

}

Builtins contains the built-in functions indexed by name.

var CmpOps = map[ComparisonOperator]cmpOpOverload{
	EQ: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeCollatedString,
			RightType: TypeCollatedString,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeBytes,
			RightType: TypeBytes,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeBool,
			RightType: TypeBool,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInterval,
			RightType: TypeInterval,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeUUID,
			RightType: TypeUUID,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeOid,
			RightType: TypeOid,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTuple,
			RightType: TypeTuple,
			// contains filtered or unexported fields
		},
	},

	LT: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeCollatedString,
			RightType: TypeCollatedString,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeBytes,
			RightType: TypeBytes,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeBool,
			RightType: TypeBool,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInterval,
			RightType: TypeInterval,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeUUID,
			RightType: TypeUUID,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTuple,
			RightType: TypeTuple,
			// contains filtered or unexported fields
		},
	},

	LE: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeCollatedString,
			RightType: TypeCollatedString,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeBytes,
			RightType: TypeBytes,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeBool,
			RightType: TypeBool,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeInt,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInt,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDecimal,
			RightType: TypeFloat,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeFloat,
			RightType: TypeDecimal,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeTimestampTZ,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeDate,
			RightType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestampTZ,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTimestamp,
			RightType: TypeDate,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeInterval,
			RightType: TypeInterval,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeUUID,
			RightType: TypeUUID,
			// contains filtered or unexported fields
		},
		CmpOp{
			LeftType:  TypeTuple,
			RightType: TypeTuple,
			// contains filtered or unexported fields
		},
	},

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

	Like: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
	},

	ILike: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
	},

	SimilarTo: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
	},

	RegMatch: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
	},

	RegIMatch: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// contains filtered or unexported fields
		},
	},
}

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 HelpMessages = func(h map[string]HelpMessageBody) map[string]HelpMessageBody {
	appendSeeAlso := func(newItem, prevItems string) string {

		if prevItems != "" {
			return newItem + "\n  " + prevItems
		}
		return newItem
	}
	reformatSeeAlso := func(seeAlso string) string {
		return strings.Replace(
			strings.Replace(seeAlso, ", ", "\n  ", -1),
			"WEBDOCS", docsURLBase, -1)
	}
	srcMsg := h["<SOURCE>"]
	srcMsg.SeeAlso = reformatSeeAlso(strings.TrimSpace(srcMsg.SeeAlso))
	selectMsg := h["<SELECTCLAUSE>"]
	selectMsg.SeeAlso = reformatSeeAlso(strings.TrimSpace(selectMsg.SeeAlso))
	for k, m := range h {
		m = h[k]
		m.ShortDescription = strings.TrimSpace(m.ShortDescription)
		m.Text = strings.TrimSpace(m.Text)
		m.SeeAlso = strings.TrimSpace(m.SeeAlso)

		if strings.Contains(m.Text, "<source>") && k != "<SOURCE>" {
			m.Text = strings.TrimSpace(m.Text) + "\n\n" + strings.TrimSpace(srcMsg.Text)
			m.SeeAlso = appendSeeAlso(srcMsg.SeeAlso, m.SeeAlso)
		}

		if strings.Contains(m.Text, "<selectclause>") && k != "<SELECTCLAUSE>" {
			m.Text = strings.TrimSpace(m.Text) + "\n\n" + strings.TrimSpace(selectMsg.Text)
			m.SeeAlso = appendSeeAlso(selectMsg.SeeAlso, m.SeeAlso)
		}

		if strings.Contains(m.Text, "<tablename>") {
			m.SeeAlso = appendSeeAlso("SHOW TABLES", m.SeeAlso)
		}
		m.SeeAlso = reformatSeeAlso(m.SeeAlso)
		h[k] = m
	}
	return h
}(helpMessages)

HelpMessages is the registry of all help messages, keyed by the top-level statement that they document. The key is intended for use via the \h client-side command.

var OidToType = map[oid.Oid]Type{
	oid.T_anyelement:   TypeAny,
	oid.T_bool:         TypeBool,
	oid.T__bool:        TArray{TypeBool},
	oid.T_bytea:        TypeBytes,
	oid.T__bytea:       TArray{TypeBytes},
	oid.T_date:         TypeDate,
	oid.T__date:        TArray{TypeDate},
	oid.T_float4:       typeFloat4,
	oid.T__float4:      TArray{typeFloat4},
	oid.T_float8:       TypeFloat,
	oid.T__float8:      TArray{TypeFloat},
	oid.T_int2:         typeInt2,
	oid.T_int4:         typeInt4,
	oid.T_int8:         TypeInt,
	oid.T_int2vector:   TypeIntVector,
	oid.T_interval:     TypeInterval,
	oid.T__interval:    TArray{TypeInterval},
	oid.T_name:         TypeName,
	oid.T__name:        TArray{TypeName},
	oid.T_numeric:      TypeDecimal,
	oid.T__numeric:     TArray{TypeDecimal},
	oid.T_oid:          TypeOid,
	oid.T__oid:         TArray{TypeOid},
	oid.T_regclass:     TypeRegClass,
	oid.T_regnamespace: TypeRegNamespace,
	oid.T_regproc:      TypeRegProc,
	oid.T_regprocedure: TypeRegProcedure,
	oid.T_regtype:      TypeRegType,
	oid.T__text:        TArray{TypeString},
	oid.T__int2:        typeInt2Array,
	oid.T__int4:        typeInt4Array,
	oid.T__int8:        TArray{TypeInt},
	oid.T_record:       TypeTuple,
	oid.T_text:         TypeString,
	oid.T_timestamp:    TypeTimestamp,
	oid.T__timestamp:   TArray{TypeTimestamp},
	oid.T_timestamptz:  TypeTimestampTZ,
	oid.T__timestamptz: TArray{TypeTimestampTZ},
	oid.T_uuid:         TypeUUID,
	oid.T__uuid:        TArray{TypeUUID},
	oid.T_varchar:      typeVarChar,
	oid.T__varchar:     TArray{typeVarChar},
}

OidToType maps Postgres object IDs to CockroachDB types.

var UnaryOps = map[UnaryOperator]unaryOpOverload{
	UnaryPlus: {
		UnaryOp{
			Typ:        TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		UnaryOp{
			Typ:        TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		UnaryOp{
			Typ:        TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
	},

	UnaryMinus: {
		UnaryOp{
			Typ:        TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
		UnaryOp{
			Typ:        TypeFloat,
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		UnaryOp{
			Typ:        TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		UnaryOp{
			Typ:        TypeInterval,
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
	},

	UnaryComplement: {
		UnaryOp{
			Typ:        TypeInt,
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},
}

UnaryOps contains the unary operations indexed by operation type.

func AsString

func AsString(n NodeFormatter) string

AsString pretty prints a node to a string.

func AsStringWithFlags

func AsStringWithFlags(n NodeFormatter, f FmtFlags) string

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

func ContainsVars

func ContainsVars(expr Expr) bool

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

func ErrString

func ErrString(n NodeFormatter) string

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

func EscapeSQLString

func EscapeSQLString(in string) string

EscapeSQLString returns an escaped SQL representation of the given string. This is suitable for safely producing a SQL string valid for input to the parser.

func ExprDebugString

func ExprDebugString(expr Expr) string

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

func FindEqualComparisonFunction

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

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

func HasReturningClause(clause ReturningClause) bool

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

func IsNumericOne

func IsNumericOne(expr TypedExpr) bool

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

func IsNumericZero

func IsNumericZero(expr TypedExpr) bool

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

func LimitDecimalWidth

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

LimitDecimalWidth limits d's precision (total number of digits) and scale (number of digits after the decimal point).

func NewInvalidNameErrorf

func NewInvalidNameErrorf(fmt string, args ...interface{}) error

NewInvalidNameErrorf initializes an error carrying the pg code CodeInvalidNameError.

func PGDisplayName

func PGDisplayName(typ Type) string

PGDisplayName returns the Postgres display name for a given type.

func PGIOBuiltinPrefix

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 Serialize

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

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

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

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

func WalkExprConst(v Visitor, expr Expr)

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

type AggregateFunc

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

func NewIdentAggregate(*EvalContext) AggregateFunc

NewIdentAggregate returns an identAggregate (see comment on struct).

type AliasClause

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

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

Format implements the NodeFormatter interface.

type AliasedTableExpr

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

AliasedTableExpr represents a table expression coupled with an optional alias.

func (*AliasedTableExpr) Format

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

Format implements the NodeFormatter interface.

func (*AliasedTableExpr) String

func (node *AliasedTableExpr) String() string

type AllColumnsSelector

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

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

Eval implements the TypedExpr interface.

func (*AllColumnsSelector) Format

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

Format implements the NodeFormatter interface.

func (*AllColumnsSelector) NormalizeVarName

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

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

func (*AllColumnsSelector) ResolvedType

func (*AllColumnsSelector) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*AllColumnsSelector) String

func (a *AllColumnsSelector) String() string

func (*AllColumnsSelector) TypeCheck

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

TypeCheck implements the Expr interface.

func (*AllColumnsSelector) Variable

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

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

Walk implements the Expr interface.

type AllTablesSelector

type AllTablesSelector struct {
	Database                Name
	DBNameOriginallyOmitted bool
}

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

func (*AllTablesSelector) Format

func (at *AllTablesSelector) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*AllTablesSelector) NormalizeTablePattern

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

NormalizeTablePattern implements the TablePattern interface.

func (*AllTablesSelector) QualifyWithDatabase

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

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

func (*AllTablesSelector) String

func (at *AllTablesSelector) String() string

type AlterTable

type AlterTable struct {
	IfExists bool
	Table    NormalizableTableName
	Cmds     AlterTableCmds
}

AlterTable represents an ALTER TABLE statement.

func (*AlterTable) Format

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

Format implements the NodeFormatter interface.

func (*AlterTable) StatementTag

func (*AlterTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTable) StatementType

func (*AlterTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTable) String

func (n *AlterTable) String() string

type AlterTableAddColumn

type AlterTableAddColumn struct {
	IfNotExists bool
	ColumnDef   *ColumnTableDef
	// contains filtered or unexported fields
}

AlterTableAddColumn represents an ADD COLUMN command.

func (*AlterTableAddColumn) Format

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

Format implements the NodeFormatter interface.

func (*AlterTableAddColumn) String

func (n *AlterTableAddColumn) String() string

type AlterTableAddConstraint

type AlterTableAddConstraint struct {
	ConstraintDef      ConstraintTableDef
	ValidationBehavior ValidationBehavior
}

AlterTableAddConstraint represents an ADD CONSTRAINT command.

func (*AlterTableAddConstraint) Format

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

Format implements the NodeFormatter interface.

func (*AlterTableAddConstraint) String

func (n *AlterTableAddConstraint) String() string

type AlterTableCmd

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

AlterTableCmd represents a table modification operation.

type AlterTableCmds

type AlterTableCmds []AlterTableCmd

AlterTableCmds represents a list of table alterations.

func (AlterTableCmds) Format

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

Format implements the NodeFormatter interface.

func (AlterTableCmds) String

func (n AlterTableCmds) String() string

type AlterTableDropColumn

type AlterTableDropColumn struct {
	IfExists     bool
	Column       Name
	DropBehavior DropBehavior
	// contains filtered or unexported fields
}

AlterTableDropColumn represents a DROP COLUMN command.

func (*AlterTableDropColumn) Format

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

Format implements the NodeFormatter interface.

func (*AlterTableDropColumn) String

func (n *AlterTableDropColumn) String() string

type AlterTableDropConstraint

type AlterTableDropConstraint struct {
	IfExists     bool
	Constraint   Name
	DropBehavior DropBehavior
}

AlterTableDropConstraint represents a DROP CONSTRAINT command.

func (*AlterTableDropConstraint) Format

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

Format implements the NodeFormatter interface.

func (*AlterTableDropConstraint) String

func (n *AlterTableDropConstraint) String() string

type AlterTableDropNotNull

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

AlterTableDropNotNull represents an ALTER COLUMN DROP NOT NULL command.

func (*AlterTableDropNotNull) Format

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

Format implements the NodeFormatter interface.

func (*AlterTableDropNotNull) GetColumn

func (node *AlterTableDropNotNull) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableDropNotNull) String

func (n *AlterTableDropNotNull) String() string

type AlterTableSetDefault

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

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

Format implements the NodeFormatter interface.

func (*AlterTableSetDefault) GetColumn

func (node *AlterTableSetDefault) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableSetDefault) String

func (n *AlterTableSetDefault) String() string

type AlterTableValidateConstraint

type AlterTableValidateConstraint struct {
	Constraint Name
}

AlterTableValidateConstraint represents a VALIDATE CONSTRAINT command.

func (*AlterTableValidateConstraint) Format

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

Format implements the NodeFormatter interface.

type AndExpr

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

AndExpr represents an AND expression.

func NewTypedAndExpr

func NewTypedAndExpr(left, right TypedExpr) *AndExpr

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

func (*AndExpr) Eval

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

Eval implements the TypedExpr interface.

func (*AndExpr) Format

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

Format implements the NodeFormatter interface.

func (AndExpr) ResolvedType

func (ta AndExpr) ResolvedType() Type

func (*AndExpr) String

func (node *AndExpr) String() string

func (*AndExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*AndExpr) TypedLeft

func (node *AndExpr) TypedLeft() TypedExpr

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

func (*AndExpr) TypedRight

func (node *AndExpr) TypedRight() TypedExpr

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

func (*AndExpr) Walk

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

Walk implements the Expr interface.

type AnnotateTypeExpr

type AnnotateTypeExpr struct {
	Expr Expr
	Type CastTargetType
	// contains filtered or unexported fields
}

AnnotateTypeExpr represents a ANNOTATE_TYPE(expr, type) expression.

func (*AnnotateTypeExpr) Format

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

Format implements the NodeFormatter interface.

func (*AnnotateTypeExpr) String

func (node *AnnotateTypeExpr) String() string

func (*AnnotateTypeExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*AnnotateTypeExpr) TypedInnerExpr

func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr

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

func (*AnnotateTypeExpr) Walk

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

Walk implements the Expr interface.

type ArgTypes

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

func (a ArgTypes) Length() int

Length implements the typeList interface.

func (ArgTypes) String

func (a ArgTypes) String() string

func (ArgTypes) Types

func (a ArgTypes) Types() []Type

Types implements the typeList interface.

type Array

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

Array represents an array constructor.

func (*Array) Eval

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

Eval implements the TypedExpr interface.

func (*Array) Format

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

Format implements the NodeFormatter interface.

func (Array) ResolvedType

func (ta Array) ResolvedType() Type

func (*Array) String

func (node *Array) String() string

func (*Array) TypeCheck

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

TypeCheck implements the Expr interface.

func (*Array) Walk

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

Walk implements the Expr interface.

type ArrayColType

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

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

Format implements the NodeFormatter interface.

func (*ArrayColType) String

func (node *ArrayColType) String() string

type ArrayFlatten

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

ArrayFlatten represents a subquery array constructor.

func (*ArrayFlatten) Eval

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

Eval implements the TypedExpr interface.

func (*ArrayFlatten) Format

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

Format implements the NodeFormatter interface.

func (ArrayFlatten) ResolvedType

func (ta ArrayFlatten) ResolvedType() Type

func (*ArrayFlatten) String

func (node *ArrayFlatten) String() string

func (*ArrayFlatten) TypeCheck

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

TypeCheck implements the Expr interface.

func (*ArrayFlatten) Walk

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

Walk implements the Expr interface.

type ArraySubscript

type ArraySubscript struct {
	Begin Expr
	End   Expr
	Slice bool
}

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

func (*ArraySubscript) Format

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

Format implements the NodeFormatter interface.

type ArraySubscripts

type ArraySubscripts []*ArraySubscript

ArraySubscripts represents a sequence of one or more array subscripts.

func (ArraySubscripts) Format

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

Format implements the NodeFormatter interface.

type AsOfClause

type AsOfClause struct {
	Expr Expr
}

AsOfClause represents an as of time.

func (AsOfClause) Format

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

Format implements the NodeFormatter interface.

type Backup

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

Backup represents a BACKUP statement.

func (*Backup) CopyNode

func (stmt *Backup) CopyNode() *Backup

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

func (*Backup) Format

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

Format implements the NodeFormatter interface.

func (*Backup) StatementTag

func (*Backup) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Backup) StatementType

func (*Backup) StatementType() StatementType

StatementType implements the Statement interface.

func (*Backup) String

func (n *Backup) String() string

func (*Backup) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type BeginTransaction

type BeginTransaction struct {
	Modes TransactionModes
}

BeginTransaction represents a BEGIN statement

func (*BeginTransaction) Format

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

Format implements the NodeFormatter interface.

func (*BeginTransaction) StatementTag

func (*BeginTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*BeginTransaction) StatementType

func (*BeginTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*BeginTransaction) String

func (n *BeginTransaction) String() string

type BinOp

type BinOp struct {
	LeftType   Type
	RightType  Type
	ReturnType Type
	// contains filtered or unexported fields
}

BinOp is a binary operator.

type BinaryExpr

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

BinaryExpr represents a binary value expression.

func (*BinaryExpr) Eval

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

Eval implements the TypedExpr interface.

func (*BinaryExpr) Format

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

Format implements the NodeFormatter interface.

func (BinaryExpr) ResolvedType

func (ta BinaryExpr) ResolvedType() Type

func (*BinaryExpr) String

func (node *BinaryExpr) String() string

func (*BinaryExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*BinaryExpr) TypedLeft

func (node *BinaryExpr) TypedLeft() TypedExpr

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

func (*BinaryExpr) TypedRight

func (node *BinaryExpr) TypedRight() TypedExpr

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

func (*BinaryExpr) Walk

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

Walk implements the Expr interface.

type BinaryOperator

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

func (i BinaryOperator) String() string

type BoolColType

type BoolColType struct {
	Name string
}

BoolColType represents a BOOLEAN type.

func (*BoolColType) Format

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

Format implements the NodeFormatter interface.

func (*BoolColType) String

func (node *BoolColType) String() string

type Builtin

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

func (b Builtin) Category() string

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

func (Builtin) Class

func (b Builtin) Class() FunctionClass

Class returns the FunctionClass of this builtin.

func (Builtin) DistSQLBlacklist

func (b Builtin) DistSQLBlacklist() bool

DistSQLBlacklist returns true if the builtin is not supported by DistSQL. See distsqlBlacklist.

func (Builtin) FixedReturnType

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

func (b Builtin) Fn() func(*EvalContext, Datums) (Datum, error)

Fn returns the Go function which implements the builtin.

func (Builtin) Impure

func (b Builtin) Impure() bool

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

func (Builtin) Signature

func (b Builtin) Signature() string

Signature returns a human-readable signature.

type BytesColType

type BytesColType struct {
	Name string
}

BytesColType represents a BYTES or BLOB type.

func (*BytesColType) Format

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

Format implements the NodeFormatter interface.

func (*BytesColType) String

func (node *BytesColType) String() string

type CancelJob

type CancelJob struct {
	ID Expr
}

CancelJob represents a CANCEL JOB statement.

func (*CancelJob) Format

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

Format implements the NodeFormatter interface.

func (*CancelJob) StatementTag

func (*CancelJob) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CancelJob) StatementType

func (*CancelJob) StatementType() StatementType

StatementType implements the Statement interface.

func (*CancelJob) String

func (n *CancelJob) String() string

type CancelQuery

type CancelQuery struct {
	ID Expr
}

CancelQuery represents a CANCEL QUERY statement.

func (*CancelQuery) Format

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

Format implements the NodeFormatter interface.

func (*CancelQuery) StatementTag

func (*CancelQuery) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CancelQuery) StatementType

func (*CancelQuery) StatementType() StatementType

StatementType implements the Statement interface.

func (*CancelQuery) String

func (n *CancelQuery) String() string

type CaseExpr

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

CaseExpr represents a CASE expression.

func (*CaseExpr) CopyNode

func (expr *CaseExpr) CopyNode() *CaseExpr

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

func (*CaseExpr) Eval

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

Eval implements the TypedExpr interface.

func (*CaseExpr) Format

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

Format implements the NodeFormatter interface.

func (CaseExpr) ResolvedType

func (ta CaseExpr) ResolvedType() Type

func (*CaseExpr) String

func (node *CaseExpr) String() string

func (*CaseExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*CaseExpr) Walk

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

Walk implements the Expr interface.

type CastExpr

type CastExpr struct {
	Expr Expr
	Type CastTargetType
	// contains filtered or unexported fields
}

CastExpr represents a CAST(expr AS type) expression.

func (*CastExpr) Eval

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

Eval implements the TypedExpr interface.

func (*CastExpr) Format

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

Format implements the NodeFormatter interface.

func (CastExpr) ResolvedType

func (ta CastExpr) ResolvedType() Type

func (*CastExpr) String

func (node *CastExpr) String() string

func (*CastExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*CastExpr) Walk

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

Walk implements the Expr interface.

type CastTargetType

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

CastTargetType represents a type that is a valid cast target.

func ParseType

func ParseType(sql string) (CastTargetType, error)

ParseType parses a column type.

type CheckConstraintTableDef

type CheckConstraintTableDef struct {
	Name Name
	Expr Expr
}

CheckConstraintTableDef represents a check constraint within a CREATE TABLE statement.

func (*CheckConstraintTableDef) Format

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

Format implements the NodeFormatter interface.

type CmpOp

type CmpOp struct {
	LeftType  Type
	RightType Type
	// contains filtered or unexported fields
}

CmpOp is a comparison operator.

type CoalesceExpr

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

CoalesceExpr represents a COALESCE or IFNULL expression.

func (*CoalesceExpr) CopyNode

func (expr *CoalesceExpr) CopyNode() *CoalesceExpr

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

func (*CoalesceExpr) Eval

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

Eval implements the TypedExpr interface.

func (*CoalesceExpr) Format

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

Format implements the NodeFormatter interface.

func (CoalesceExpr) ResolvedType

func (ta CoalesceExpr) ResolvedType() Type

func (*CoalesceExpr) String

func (node *CoalesceExpr) String() string

func (*CoalesceExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*CoalesceExpr) TypedExprAt

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

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

func (*CoalesceExpr) Walk

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

Walk implements the Expr interface.

type CollateExpr

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

CollateExpr represents an (expr COLLATE locale) expression.

func (*CollateExpr) Eval

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

Eval implements the TypedExpr interface.

func (*CollateExpr) Format

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

Format implements the NodeFormatter interface.

func (CollateExpr) ResolvedType

func (ta CollateExpr) ResolvedType() Type

func (*CollateExpr) String

func (node *CollateExpr) String() string

func (*CollateExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*CollateExpr) Walk

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

Walk implements the Expr interface.

type CollatedStringColType

type CollatedStringColType struct {
	Name   string
	N      int
	Locale string
}

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

func (*CollatedStringColType) Format

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

Format implements the NodeFormatter interface.

func (*CollatedStringColType) String

func (node *CollatedStringColType) String() string

type CollationEnvironment

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

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

type ColumnCheckConstraint

type ColumnCheckConstraint struct {
	Expr Expr
}

ColumnCheckConstraint represents either a check on a column.

type ColumnCollation

type ColumnCollation string

ColumnCollation represents a COLLATE clause for a column.

type ColumnDefault

type ColumnDefault struct {
	Expr Expr
}

ColumnDefault represents a DEFAULT clause for a column.

type ColumnFKConstraint

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

ColumnFKConstraint represents a FK-constaint on a column.

type ColumnFamilyConstraint

type ColumnFamilyConstraint struct {
	Family      Name
	Create      bool
	IfNotExists bool
}

ColumnFamilyConstraint represents FAMILY on a column.

type ColumnID

type ColumnID uint32

ColumnID is a custom type for ColumnDescriptor IDs.

type ColumnItem

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

func (c *ColumnItem) Column() string

Column retrieves the unqualified column name.

func (*ColumnItem) Eval

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

Eval implements the TypedExpr interface.

func (*ColumnItem) Format

func (c *ColumnItem) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*ColumnItem) NormalizeVarName

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

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

func (*ColumnItem) ResolvedType

func (c *ColumnItem) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*ColumnItem) String

func (c *ColumnItem) String() string

func (*ColumnItem) TypeCheck

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

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

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

Walk implements the Expr interface.

type ColumnMutationCmd

type ColumnMutationCmd interface {
	AlterTableCmd
	GetColumn() Name
}

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

type ColumnQualification

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

ColumnQualification represents a constraint on a column.

type ColumnTableDef

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

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

Format implements the NodeFormatter interface.

func (*ColumnTableDef) HasColumnFamily

func (node *ColumnTableDef) HasColumnFamily() bool

HasColumnFamily returns if the ColumnTableDef has a column family.

func (*ColumnTableDef) HasDefaultExpr

func (node *ColumnTableDef) HasDefaultExpr() bool

HasDefaultExpr returns if the ColumnTableDef has a default expression.

func (*ColumnTableDef) HasFKConstraint

func (node *ColumnTableDef) HasFKConstraint() bool

HasFKConstraint returns if the ColumnTableDef has a foreign key constraint.

type ColumnTableDefCheckExpr

type ColumnTableDefCheckExpr struct {
	Expr           Expr
	ConstraintName Name
}

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

type ColumnType

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

ColumnType represents a type in a column definition.

func DatumTypeToColumnType

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.

func StringToColType

func StringToColType(s string) (ColumnType, error)

StringToColType returns a column type given a string representation of the type. Used by dump.

type CommitTransaction

type CommitTransaction struct{}

CommitTransaction represents a COMMIT statement.

func (*CommitTransaction) Format

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

Format implements the NodeFormatter interface.

func (*CommitTransaction) StatementTag

func (*CommitTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommitTransaction) StatementType

func (*CommitTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommitTransaction) String

func (n *CommitTransaction) String() string

type ComparisonExpr

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

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

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

func (*ComparisonExpr) Eval

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

Eval implements the TypedExpr interface.

func (*ComparisonExpr) Format

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

Format implements the NodeFormatter interface.

func (*ComparisonExpr) IsMixedTypeComparison

func (node *ComparisonExpr) IsMixedTypeComparison() bool

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

func (ComparisonExpr) ResolvedType

func (ta ComparisonExpr) ResolvedType() Type

func (*ComparisonExpr) String

func (node *ComparisonExpr) String() string

func (*ComparisonExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*ComparisonExpr) TypedLeft

func (node *ComparisonExpr) TypedLeft() TypedExpr

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

func (*ComparisonExpr) TypedRight

func (node *ComparisonExpr) TypedRight() TypedExpr

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

func (*ComparisonExpr) Walk

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

Walk implements the Expr interface.

type ComparisonOperator

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

func (i ComparisonOperator) String() string

type CompositeDatum

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

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
	// DesirableTypes returns the ordered set of types that the constant would
	// prefer to be resolved into. As in AvailableTypes, the order of the returned
	// type slice provides a notion of precedence, with the first element in the
	// ordering being the Constant's "natural type." The function is meant to be
	// differentiated from AvailableTypes in that it will exclude certain types
	// that are possible, but not desirable.
	//
	// An example of this is a floating point numeric constant without a value
	// past the decimal point. It is possible to resolve this constant as a
	// decimal, but it is not desirable.
	DesirableTypes() []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

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

ConstraintTableDef represents a constraint definition within a CREATE TABLE statement.

type ContainsWindowVisitor

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

ContainsWindowVisitor checks if walked expressions contain window functions.

func (*ContainsWindowVisitor) ContainsWindowFunc

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

ContainsWindowFunc determines if an Expr contains a window function.

func (*ContainsWindowVisitor) VisitPost

func (*ContainsWindowVisitor) VisitPost(expr Expr) Expr

VisitPost satisfies the Visitor interface.

func (*ContainsWindowVisitor) VisitPre

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

VisitPre satisfies the Visitor interface.

type CopyFrom

type CopyFrom struct {
	Table   NormalizableTableName
	Columns UnresolvedNames
	Stdin   bool
}

CopyFrom represents a COPY FROM statement.

func (*CopyFrom) Format

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

Format implements the NodeFormatter interface.

func (*CopyFrom) StatementTag

func (*CopyFrom) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CopyFrom) StatementType

func (*CopyFrom) StatementType() StatementType

StatementType implements the Statement interface.

func (*CopyFrom) String

func (n *CopyFrom) String() string

type CreateDatabase

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

CreateDatabase represents a CREATE DATABASE statement.

func (*CreateDatabase) Format

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

Format implements the NodeFormatter interface.

func (*CreateDatabase) StatementTag

func (*CreateDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateDatabase) StatementType

func (*CreateDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateDatabase) String

func (n *CreateDatabase) String() string

type CreateIndex

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

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

Format implements the NodeFormatter interface.

func (*CreateIndex) StatementTag

func (*CreateIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateIndex) StatementType

func (*CreateIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateIndex) String

func (n *CreateIndex) String() string

type CreateTable

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

func (node *CreateTable) As() bool

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

func (*CreateTable) Format

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

Format implements the NodeFormatter interface.

func (*CreateTable) StatementTag

func (n *CreateTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateTable) StatementType

func (*CreateTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateTable) String

func (n *CreateTable) String() string

type CreateUser

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

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

Format implements the NodeFormatter interface.

func (*CreateUser) HasPassword

func (node *CreateUser) HasPassword() bool

HasPassword returns if the CreateUser has a password.

func (*CreateUser) StatementTag

func (*CreateUser) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateUser) StatementType

func (*CreateUser) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateUser) String

func (n *CreateUser) String() string

type CreateView

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

CreateView represents a CREATE VIEW statement.

func (*CreateView) Format

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

Format implements the NodeFormatter interface.

func (*CreateView) StatementTag

func (*CreateView) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateView) StatementType

func (*CreateView) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateView) String

func (n *CreateView) String() string

type DArray

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

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

func MustBeDArray(e Expr) *DArray

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

func NewDArray

func NewDArray(paramTyp Type) *DArray

NewDArray returns a DArray containing elements of the specified type.

func ParseDArrayFromString

func ParseDArrayFromString(evalCtx *EvalContext, s string, t ColumnType) (*DArray, error)

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

func (*DArray) AmbiguousFormat

func (*DArray) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DArray) Append

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

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

Compare implements the Datum interface.

func (*DArray) Eval

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

Eval implements the TypedExpr interface.

func (*DArray) Format

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

Format implements the NodeFormatter interface.

func (*DArray) IsMax

func (d *DArray) IsMax() bool

IsMax implements the Datum interface.

func (*DArray) IsMin

func (d *DArray) IsMin() bool

IsMin implements the Datum interface.

func (*DArray) Len

func (d *DArray) Len() int

Len returns the length of the Datum array.

func (*DArray) Next

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

Next implements the Datum interface.

func (*DArray) Prev

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

Prev implements the Datum interface.

func (*DArray) ResolvedType

func (d *DArray) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DArray) Size

func (d *DArray) Size() uintptr

Size implements the Datum interface.

func (*DArray) String

func (node *DArray) String() string

func (*DArray) TypeCheck

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

func (d *DArray) Validate() error

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

func (*DArray) Walk

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

Walk implements the Expr interface.

type DBool

type DBool bool

DBool is the boolean Datum.

func GetBool

func GetBool(d Datum) (DBool, error)

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

func MakeDBool

func MakeDBool(d DBool) *DBool

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

func ParseDBool

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

func (*DBool) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBool) Compare

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

Compare implements the Datum interface.

func (*DBool) Eval

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

Eval implements the TypedExpr interface.

func (*DBool) Format

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

Format implements the NodeFormatter interface.

func (*DBool) IsMax

func (d *DBool) IsMax() bool

IsMax implements the Datum interface.

func (*DBool) IsMin

func (d *DBool) IsMin() bool

IsMin implements the Datum interface.

func (*DBool) Next

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

Next implements the Datum interface.

func (*DBool) Prev

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

Prev implements the Datum interface.

func (*DBool) ResolvedType

func (*DBool) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DBool) Size

func (d *DBool) Size() uintptr

Size implements the Datum interface.

func (*DBool) String

func (node *DBool) String() string

func (*DBool) TypeCheck

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

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

Walk implements the Expr interface.

type DBytes

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

func NewDBytes(d DBytes) *DBytes

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

func ParseDByte

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

ParseDByte parses a string representation of hex encoded binary data.

func (*DBytes) AmbiguousFormat

func (*DBytes) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBytes) Compare

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

Compare implements the Datum interface.

func (*DBytes) Eval

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

Eval implements the TypedExpr interface.

func (*DBytes) Format

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

Format implements the NodeFormatter interface.

func (*DBytes) IsMax

func (*DBytes) IsMax() bool

IsMax implements the Datum interface.

func (*DBytes) IsMin

func (d *DBytes) IsMin() bool

IsMin implements the Datum interface.

func (*DBytes) Next

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

Next implements the Datum interface.

func (*DBytes) Prev

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

Prev implements the Datum interface.

func (*DBytes) ResolvedType

func (*DBytes) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DBytes) Size

func (d *DBytes) Size() uintptr

Size implements the Datum interface.

func (*DBytes) String

func (node *DBytes) String() string

func (*DBytes) TypeCheck

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

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

Walk implements the Expr interface.

type DCollatedString

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

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

func (*DCollatedString) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DCollatedString) Compare

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

Compare implements the Datum interface.

func (*DCollatedString) Eval

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

Eval implements the TypedExpr interface.

func (*DCollatedString) Format

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

Format implements the NodeFormatter interface.

func (*DCollatedString) IsComposite

func (d *DCollatedString) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DCollatedString) IsMax

func (*DCollatedString) IsMax() bool

IsMax implements the Datum interface.

func (*DCollatedString) IsMin

func (d *DCollatedString) IsMin() bool

IsMin implements the Datum interface.

func (*DCollatedString) Next

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

Next implements the Datum interface.

func (*DCollatedString) Prev

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

Prev implements the Datum interface.

func (*DCollatedString) ResolvedType

func (d *DCollatedString) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DCollatedString) Size

func (d *DCollatedString) Size() uintptr

Size implements the Datum interface.

func (*DCollatedString) String

func (node *DCollatedString) String() string

func (*DCollatedString) TypeCheck

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

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

Walk implements the Expr interface.

type DDate

type DDate int64

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

func NewDDate

func NewDDate(d DDate) *DDate

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

func NewDDateFromTime

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

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

func ParseDDate

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

func (*DDate) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDate) Compare

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

Compare implements the Datum interface.

func (*DDate) Eval

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

Eval implements the TypedExpr interface.

func (*DDate) Format

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

Format implements the NodeFormatter interface.

func (*DDate) IsMax

func (d *DDate) IsMax() bool

IsMax implements the Datum interface.

func (*DDate) IsMin

func (d *DDate) IsMin() bool

IsMin implements the Datum interface.

func (*DDate) Next

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

Next implements the Datum interface.

func (*DDate) Prev

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

Prev implements the Datum interface.

func (*DDate) ResolvedType

func (*DDate) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DDate) Size

func (d *DDate) Size() uintptr

Size implements the Datum interface.

func (*DDate) String

func (node *DDate) String() string

func (*DDate) TypeCheck

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

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

Walk implements the Expr interface.

type DDecimal

type DDecimal struct {
	apd.Decimal
}

DDecimal is the decimal Datum.

var DecimalOne DDecimal

DecimalOne represents the constant 1 as DECIMAL.

func ParseDDecimal

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

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

func (*DDecimal) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDecimal) Compare

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

Compare implements the Datum interface.

func (*DDecimal) Eval

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

Eval implements the TypedExpr interface.

func (*DDecimal) Format

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

Format implements the NodeFormatter interface.

func (*DDecimal) IsComposite

func (d *DDecimal) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DDecimal) IsMax

func (*DDecimal) IsMax() bool

IsMax implements the Datum interface.

func (*DDecimal) IsMin

func (*DDecimal) IsMin() bool

IsMin implements the Datum interface.

func (*DDecimal) Next

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

Next implements the Datum interface.

func (*DDecimal) Prev

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

Prev implements the Datum interface.

func (*DDecimal) ResolvedType

func (*DDecimal) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DDecimal) SetString

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

func (d *DDecimal) Size() uintptr

Size implements the Datum interface.

func (*DDecimal) String

func (node *DDecimal) String() string

func (*DDecimal) TypeCheck

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

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

Walk implements the Expr interface.

type DFloat

type DFloat float64

DFloat is the float Datum.

func NewDFloat

func NewDFloat(d DFloat) *DFloat

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

func ParseDFloat

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

func (*DFloat) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DFloat) Compare

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

Compare implements the Datum interface.

func (*DFloat) Eval

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

Eval implements the TypedExpr interface.

func (*DFloat) Format

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

Format implements the NodeFormatter interface.

func (*DFloat) IsComposite

func (d *DFloat) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DFloat) IsMax

func (d *DFloat) IsMax() bool

IsMax implements the Datum interface.

func (*DFloat) IsMin

func (d *DFloat) IsMin() bool

IsMin implements the Datum interface.

func (*DFloat) Next

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

Next implements the Datum interface.

func (*DFloat) Prev

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

Prev implements the Datum interface.

func (*DFloat) ResolvedType

func (*DFloat) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DFloat) Size

func (d *DFloat) Size() uintptr

Size implements the Datum interface.

func (*DFloat) String

func (node *DFloat) String() string

func (*DFloat) TypeCheck

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

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

Walk implements the Expr interface.

type DInt

type DInt int64

DInt is the int Datum.

func AsDInt

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

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

func MustBeDInt(e Expr) DInt

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

func NewDInt

func NewDInt(d DInt) *DInt

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

func ParseDInt

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

func (*DInt) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInt) Compare

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

Compare implements the Datum interface.

func (*DInt) Eval

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

Eval implements the TypedExpr interface.

func (*DInt) Format

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

Format implements the NodeFormatter interface.

func (*DInt) IsMax

func (d *DInt) IsMax() bool

IsMax implements the Datum interface.

func (*DInt) IsMin

func (d *DInt) IsMin() bool

IsMin implements the Datum interface.

func (*DInt) Next

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

Next implements the Datum interface.

func (*DInt) Prev

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

Prev implements the Datum interface.

func (*DInt) ResolvedType

func (*DInt) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DInt) Size

func (d *DInt) Size() uintptr

Size implements the Datum interface.

func (*DInt) String

func (node *DInt) String() string

func (*DInt) TypeCheck

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

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

Walk implements the Expr interface.

type DInterval

type DInterval struct {
	duration.Duration
}

DInterval is the interval Datum.

func ParseDInterval

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

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

func (*DInterval) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInterval) Compare

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

Compare implements the Datum interface.

func (*DInterval) Eval

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

Eval implements the TypedExpr interface.

func (*DInterval) Format

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

Format implements the NodeFormatter interface.

func (*DInterval) IsMax

func (d *DInterval) IsMax() bool

IsMax implements the Datum interface.

func (*DInterval) IsMin

func (d *DInterval) IsMin() bool

IsMin implements the Datum interface.

func (*DInterval) Next

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

Next implements the Datum interface.

func (*DInterval) Prev

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

Prev implements the Datum interface.

func (*DInterval) ResolvedType

func (*DInterval) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DInterval) Size

func (d *DInterval) Size() uintptr

Size implements the Datum interface.

func (*DInterval) String

func (node *DInterval) String() string

func (*DInterval) TypeCheck

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

func (d *DInterval) ValueAsString() string

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

func (*DInterval) Walk

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

Walk implements the Expr interface.

type DOid

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

func MakeDOid(d DInt) DOid

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

func NewDOid

func NewDOid(d DInt) *DOid

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

func (*DOid) AmbiguousFormat

func (*DOid) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DOid) AsRegProc

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

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

Compare implements the Datum interface.

func (*DOid) Eval

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

Eval implements the TypedExpr interface.

func (*DOid) Format

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

Format implements the Datum interface.

func (*DOid) IsMax

func (d *DOid) IsMax() bool

IsMax implements the Datum interface.

func (*DOid) IsMin

func (d *DOid) IsMin() bool

IsMin implements the Datum interface.

func (*DOid) Next

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

Next implements the Datum interface.

func (*DOid) Prev

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

Prev implements the Datum interface.

func (*DOid) ResolvedType

func (d *DOid) ResolvedType() Type

ResolvedType implements the Datum interface.

func (*DOid) Size

func (d *DOid) Size() uintptr

Size implements the Datum interface.

func (*DOid) String

func (node *DOid) String() string

func (*DOid) TypeCheck

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

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

Walk implements the Expr interface.

type DOidWrapper

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

func (d *DOidWrapper) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DOidWrapper) Compare

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

Compare implements the Datum interface.

func (*DOidWrapper) Eval

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

Eval implements the TypedExpr interface.

func (*DOidWrapper) Format

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

Format implements the NodeFormatter interface.

func (*DOidWrapper) IsMax

func (d *DOidWrapper) IsMax() bool

IsMax implements the Datum interface.

func (*DOidWrapper) IsMin

func (d *DOidWrapper) IsMin() bool

IsMin implements the Datum interface.

func (*DOidWrapper) Next

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

Next implements the Datum interface.

func (*DOidWrapper) Prev

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

Prev implements the Datum interface.

func (*DOidWrapper) ResolvedType

func (d *DOidWrapper) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DOidWrapper) Size

func (d *DOidWrapper) Size() uintptr

Size implements the Datum interface.

func (*DOidWrapper) String

func (node *DOidWrapper) String() string

func (*DOidWrapper) TypeCheck

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

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

Walk implements the Expr interface.

type DString

type DString string

DString is the string Datum.

func AsDString

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

func MustBeDString(e Expr) DString

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

func NewDString

func NewDString(d string) *DString

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

func (*DString) AmbiguousFormat

func (*DString) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DString) Compare

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

Compare implements the Datum interface.

func (*DString) Eval

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

Eval implements the TypedExpr interface.

func (*DString) Format

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

Format implements the NodeFormatter interface.

func (*DString) IsMax

func (*DString) IsMax() bool

IsMax implements the Datum interface.

func (*DString) IsMin

func (d *DString) IsMin() bool

IsMin implements the Datum interface.

func (*DString) Next

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

Next implements the Datum interface.

func (*DString) Prev

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

Prev implements the Datum interface.

func (*DString) ResolvedType

func (*DString) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DString) Size

func (d *DString) Size() uintptr

Size implements the Datum interface.

func (*DString) String

func (node *DString) String() string

func (*DString) TypeCheck

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

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

Walk implements the Expr interface.

type DTable

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 EmptyDTable

func EmptyDTable() *DTable

EmptyDTable returns a new, empty DTable.

func (*DTable) AmbiguousFormat

func (*DTable) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTable) Compare

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

Compare implements the Datum interface.

func (*DTable) Eval

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

Eval implements the TypedExpr interface.

func (*DTable) Format

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

Format implements the NodeFormatter interface.

func (*DTable) IsMax

func (*DTable) IsMax() bool

IsMax implements the Datum interface.

func (*DTable) IsMin

func (*DTable) IsMin() bool

IsMin implements the Datum interface.

func (*DTable) Next

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

Next implements the Datum interface.

func (*DTable) Prev

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

Prev implements the Datum interface.

func (*DTable) ResolvedType

func (t *DTable) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTable) Size

func (*DTable) Size() uintptr

Size implements the Datum interface.

func (*DTable) String

func (node *DTable) String() string

func (*DTable) TypeCheck

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

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

Walk implements the Expr interface.

type DTimestamp

type DTimestamp struct {
	time.Time
}

DTimestamp is the timestamp Datum.

func MakeDTimestamp

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

MakeDTimestamp creates a DTimestamp with specified precision.

func ParseDTimestamp

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

func (*DTimestamp) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTimestamp) Compare

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

Compare implements the Datum interface.

func (*DTimestamp) Eval

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

Eval implements the TypedExpr interface.

func (*DTimestamp) Format

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

Format implements the NodeFormatter interface.

func (*DTimestamp) IsMax

func (d *DTimestamp) IsMax() bool

IsMax implements the Datum interface.

func (*DTimestamp) IsMin

func (d *DTimestamp) IsMin() bool

IsMin implements the Datum interface.

func (*DTimestamp) Next

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

Next implements the Datum interface.

func (*DTimestamp) Prev

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

Prev implements the Datum interface.

func (*DTimestamp) ResolvedType

func (*DTimestamp) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTimestamp) Size

func (d *DTimestamp) Size() uintptr

Size implements the Datum interface.

func (*DTimestamp) String

func (node *DTimestamp) String() string

func (*DTimestamp) TypeCheck

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

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

Walk implements the Expr interface.

type DTimestampTZ

type DTimestampTZ struct {
	time.Time
}

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

func MakeDTimestampTZ

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

MakeDTimestampTZ creates a DTimestampTZ with specified precision.

func MakeDTimestampTZFromDate

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

MakeDTimestampTZFromDate creates a DTimestampTZ from a DDate.

func ParseDTimestampTZ

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

func (*DTimestampTZ) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTimestampTZ) Compare

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

Compare implements the Datum interface.

func (*DTimestampTZ) Eval

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

Eval implements the TypedExpr interface.

func (*DTimestampTZ) Format

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

Format implements the NodeFormatter interface.

func (*DTimestampTZ) IsMax

func (d *DTimestampTZ) IsMax() bool

IsMax implements the Datum interface.

func (*DTimestampTZ) IsMin

func (d *DTimestampTZ) IsMin() bool

IsMin implements the Datum interface.

func (*DTimestampTZ) Next

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

Next implements the Datum interface.

func (*DTimestampTZ) Prev

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

Prev implements the Datum interface.

func (*DTimestampTZ) ResolvedType

func (*DTimestampTZ) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTimestampTZ) Size

func (d *DTimestampTZ) Size() uintptr

Size implements the Datum interface.

func (*DTimestampTZ) String

func (node *DTimestampTZ) String() string

func (*DTimestampTZ) TypeCheck

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

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

Walk implements the Expr interface.

type DTuple

type DTuple struct {
	D Datums

	Sorted bool
}

DTuple is the tuple Datum.

func NewDTuple

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

func NewDTupleWithCap(c int) *DTuple

NewDTupleWithCap creates a *DTuple with the provided capacity.

func NewDTupleWithLen

func NewDTupleWithLen(l int) *DTuple

NewDTupleWithLen creates a *DTuple with the provided length.

func (*DTuple) AmbiguousFormat

func (*DTuple) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTuple) AssertSorted

func (d *DTuple) AssertSorted()

AssertSorted asserts that the DTuple is sorted.

func (*DTuple) Compare

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

Compare implements the Datum interface.

func (*DTuple) Eval

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

Eval implements the TypedExpr interface.

func (*DTuple) Format

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

Format implements the NodeFormatter interface.

func (*DTuple) IsMax

func (d *DTuple) IsMax() bool

IsMax implements the Datum interface.

func (*DTuple) IsMin

func (d *DTuple) IsMin() bool

IsMin implements the Datum interface.

func (*DTuple) Next

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

Next implements the Datum interface.

func (*DTuple) Normalize

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

Normalize sorts and uniques the datum tuple.

func (*DTuple) Prev

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

Prev implements the Datum interface.

func (*DTuple) ResolvedType

func (d *DTuple) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DTuple) SearchSorted

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

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

func (d *DTuple) Size() uintptr

Size implements the Datum interface.

func (*DTuple) SortedDifference

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

func (node *DTuple) String() string

func (*DTuple) TypeCheck

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

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

Walk implements the Expr interface.

type DUuid

type DUuid struct {
	uuid.UUID
}

DUuid is the UUID Datum.

func NewDUuid

func NewDUuid(d DUuid) *DUuid

NewDUuid is a helper routine to create a *DUuid initialized from its argument.

func ParseDUuidFromBytes

func ParseDUuidFromBytes(b []byte) (*DUuid, error)

ParseDUuidFromBytes parses and returns the *DUuid Datum value represented by the provided input bytes, or an error.

func ParseDUuidFromString

func ParseDUuidFromString(s string) (*DUuid, error)

ParseDUuidFromString parses and returns the *DUuid Datum value represented by the provided input string, or an error.

func (*DUuid) AmbiguousFormat

func (*DUuid) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DUuid) Compare

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

Compare implements the Datum interface.

func (*DUuid) Eval

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

Eval implements the TypedExpr interface.

func (*DUuid) Format

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

Format implements the NodeFormatter interface.

func (*DUuid) IsMax

func (d *DUuid) IsMax() bool

IsMax implements the Datum interface.

func (*DUuid) IsMin

func (d *DUuid) IsMin() bool

IsMin implements the Datum interface.

func (*DUuid) Next

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

Next implements the Datum interface.

func (*DUuid) Prev

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

Prev implements the Datum interface.

func (*DUuid) ResolvedType

func (*DUuid) ResolvedType() Type

ResolvedType implements the TypedExpr interface.

func (*DUuid) Size

func (d *DUuid) Size() uintptr

Size implements the Datum interface.

func (*DUuid) String

func (node *DUuid) String() string

func (*DUuid) TypeCheck

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

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

func (*DUuid) Walk

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

Walk implements the Expr interface.

type DatabaseQualifiable

type DatabaseQualifiable interface {
	QualifyWithDatabase(database string) error
}

DatabaseQualifiable identifiers can be qualifed with a database name.

type DateColType

type DateColType struct {
}

DateColType represents a DATE type.

func (*DateColType) Format

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

Format implements the NodeFormatter interface.

func (*DateColType) String

func (node *DateColType) String() string

type Datum

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 satisfies the following definition: if the receiver is
	// "b" and the returned datum is "a", then for every compatible datum "x", it
	// holds that "x < b" is true if and only if "x <= a" is true.
	//
	// The return value is undefined if IsMin() returns true.
	//
	// TODO(#12022): for DTuple, the contract is actually that "x < b" (SQL order,
	// where NULL < x is unknown for all x) is true only if "x <= a"
	// (.Compare/encoding order, where NULL <= x is true for all x) is true. This
	// is okay for now: the returned datum is used only to construct a span, which
	// uses .Compare/encoding order and is guaranteed to be large enough by this
	// weaker contract. The original filter expression is left in place to catch
	// false positives.
	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 satisfies the following definition: if the
	// receiver is "a" and the returned datum is "b", then for every compatible
	// datum "x", it holds that "x > a" is true if and only if "x >= b" is true.
	//
	// The return value is undefined if IsMax() returns true.
	//
	// TODO(#12022): for DTuple, the contract is actually that "x > a" (SQL order,
	// where x > NULL is unknown for all x) is true only if "x >= b"
	// (.Compare/encoding order, where x >= NULL is true for all x) is true. This
	// is okay for now: the returned datum is used only to construct a span, which
	// uses .Compare/encoding order and is guaranteed to be large enough by this
	// weaker contract. The original filter expression is left in place to catch
	// false positives.
	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

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

func NewDName(d string) Datum

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

func NewDNameFromDString

func NewDNameFromDString(d *DString) Datum

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

func ParseStringAs

func ParseStringAs(t Type, s string, evalCtx *EvalContext) (Datum, error)

ParseStringAs parses s as type t.

func UnwrapDatum

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

type Datums []Datum

Datums is a slice of Datum values.

func (Datums) Format

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

Format implements the NodeFormatter interface.