parser

package
v0.0.0-...-a3ba52b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2016 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Distinct funcType
	All
)

FuncExpr.Type

View Source
const ACTION = 57361
View Source
const ADD = 57362
View Source
const ALL = 57363
View Source
const ALTER = 57364
View Source
const ANALYSE = 57365
View Source
const ANALYZE = 57366
View Source
const AND = 57367
View Source
const ANNOTATE_TYPE = 57369
View Source
const ANY = 57368
View Source
const ARRAY = 57370
View Source
const AS = 57371
View Source
const ASC = 57372
View Source
const ASYMMETRIC = 57373
View Source
const AS_LA = 57618
View Source
const AT = 57374
View Source
const BCONST = 57348
View Source
const BEGIN = 57375
View Source
const BETWEEN = 57376
View Source
const BIGINT = 57377
View Source
const BIGSERIAL = 57378
View Source
const BIT = 57379
View Source
const BLOB = 57380
View Source
const BOOL = 57381
View Source
const BOOLEAN = 57382
View Source
const BOTH = 57383
View Source
const BY = 57384
View Source
const BYTEA = 57385
View Source
const BYTES = 57386
View Source
const CASCADE = 57387
View Source
const CASE = 57388
View Source
const CAST = 57389
View Source
const CHAR = 57390
View Source
const CHARACTER = 57391
View Source
const CHARACTERISTICS = 57392
View Source
const CHECK = 57393
View Source
const COALESCE = 57394
View Source
const COLLATE = 57395
View Source
const COLLATION = 57396
View Source
const COLUMN = 57397
View Source
const COLUMNS = 57398
View Source
const COMMIT = 57399
View Source
const COMMITTED = 57400
View Source
const CONCAT = 57401
View Source
const CONFLICT = 57402
View Source
const CONSTRAINT = 57403
View Source
const CONSTRAINTS = 57404
View Source
const COVERING = 57405
View Source
const CREATE = 57406
View Source
const CROSS = 57407
View Source
const CUBE = 57408
View Source
const CURRENT = 57409
View Source
const CURRENT_CATALOG = 57410
View Source
const CURRENT_DATE = 57411
View Source
const CURRENT_ROLE = 57412
View Source
const CURRENT_TIME = 57413
View Source
const CURRENT_TIMESTAMP = 57414
View Source
const CURRENT_USER = 57415
View Source
const CYCLE = 57416
View Source
const DATA = 57417
View Source
const DATABASE = 57418
View Source
const DATABASES = 57419
View Source
const DATE = 57420
View Source
const DAY = 57421
View Source
const DEALLOCATE = 57425
View Source
const DEC = 57422
View Source
const DECIMAL = 57423
View Source
const DEFAULT = 57424
View Source
const DEFERRABLE = 57426
View Source
const DELETE = 57427
View Source
const DESC = 57428
View Source
const DISTINCT = 57429
View Source
const DO = 57430
View Source
const DOT_DOT = 57353
View Source
const DOUBLE = 57431
View Source
const DROP = 57432
View Source
const ELSE = 57433
View Source
const ENCODING = 57434
View Source
const END = 57435
View Source
const ERROR = 57360
View Source
const ESCAPE = 57436
View Source
const EXCEPT = 57437
View Source
const EXECUTE = 57439
View Source
const EXISTS = 57438
View Source
const EXPLAIN = 57440
View Source
const EXTRACT = 57441
View Source
const FALSE = 57442
View Source
const FAMILY = 57443
View Source
const FCONST = 57350
View Source
const FETCH = 57444
View Source
const FILTER = 57445
View Source
const FIRST = 57446
View Source
const FLOAT = 57447
View Source
const FLOORDIV = 57448
View Source
const FOLLOWING = 57449
View Source
const FOR = 57450
View Source
const FORCE_INDEX = 57451
View Source
const FOREIGN = 57452
View Source
const FROM = 57453
View Source
const FULL = 57454
View Source
const GRANT = 57455
View Source
const GRANTS = 57456
View Source
const GREATER_EQUALS = 57355
View Source
const GREATEST = 57457
View Source
const GROUP = 57458
View Source
const GROUPING = 57459
View Source
const HAVING = 57460
View Source
const HIGH = 57461
View Source
const HOUR = 57462
View Source
const ICONST = 57349
View Source
const IDENT = 57346
View Source
const IF = 57463
View Source
const IFNULL = 57464
View Source
const ILIKE = 57465
View Source
const IN = 57466
View Source
const INDEX = 57468
View Source
const INDEXES = 57469
View Source
const INITIALLY = 57470
View Source
const INNER = 57471
View Source
const INSERT = 57472
View Source
const INT = 57473
View Source
const INT64 = 57474
View Source
const INTEGER = 57475
View Source
const INTERLEAVE = 57467
View Source
const INTERSECT = 57476
View Source
const INTERVAL = 57477
View Source
const INTO = 57478
View Source
const IS = 57479
View Source
const ISOLATION = 57480
View Source
const JOIN = 57481
View Source
const KEY = 57482
View Source
const KEYS = 57483
View Source
const LATERAL = 57484
View Source
const LEADING = 57485
View Source
const LEAST = 57486
View Source
const LEFT = 57487
View Source
const LESS_EQUALS = 57354
View Source
const LEVEL = 57488
View Source
const LIKE = 57489
View Source
const LIMIT = 57490
View Source
const LOCAL = 57491
View Source
const LOCALTIME = 57492
View Source
const LOCALTIMESTAMP = 57493
View Source
const LOW = 57494
View Source
const LSHIFT = 57495
View Source
const MATCH = 57496
View Source
const MINUTE = 57497
View Source
const MONTH = 57498
View Source
const NAME = 57499
View Source
const NAMES = 57500
View Source
const NATURAL = 57501
View Source
const NEXT = 57502
View Source
const NO = 57503
View Source
const NORMAL = 57505
View Source
const NOT = 57506
View Source
const NOTHING = 57507
View Source
const NOT_EQUALS = 57356
View Source
const NOT_LA = 57616
View Source
const NOT_REGIMATCH = 57359
View Source
const NOT_REGMATCH = 57357
View Source
const NO_INDEX_JOIN = 57504
View Source
const NULL = 57508
View Source
const NULLIF = 57509
View Source
const NULLS = 57510
View Source
const NUMERIC = 57511
View Source
const OF = 57512
View Source
const OFF = 57513
View Source
const OFFSET = 57514
View Source
const ON = 57515
View Source
const ONLY = 57516
View Source
const OR = 57517
View Source
const ORDER = 57518
View Source
const ORDINALITY = 57519
View Source
const OUT = 57520
View Source
const OUTER = 57521
View Source
const OVER = 57522
View Source
const OVERLAPS = 57523
View Source
const OVERLAY = 57524
View Source
const PARENT = 57525
View Source
const PARTIAL = 57526
View Source
const PARTITION = 57527
View Source
const PLACEHOLDER = 57351
View Source
const PLACING = 57528
View Source
const POSITION = 57529
View Source
const POSTFIXOP = 57619
View Source
const PRECEDING = 57530
View Source
const PRECISION = 57531
View Source
const PREPARE = 57532
View Source
const PRIMARY = 57533
View Source
const PRIORITY = 57534
View Source
const RANGE = 57535
View Source
const READ = 57536
View Source
const REAL = 57537
View Source
const RECURSIVE = 57538
View Source
const REF = 57539
View Source
const REFERENCES = 57540
View Source
const REGIMATCH = 57358
View Source
const RELEASE = 57543
View Source
const RENAME = 57541
View Source
const REPEATABLE = 57542
View Source
const RESTRICT = 57544
View Source
const RETURNING = 57545
View Source
const REVOKE = 57546
View Source
const RIGHT = 57547
View Source
const ROLLBACK = 57548
View Source
const ROLLUP = 57549
View Source
const ROW = 57550
View Source
const ROWS = 57551
View Source
const RSHIFT = 57552
View Source
const RestartSavepointName string = "COCKROACH_RESTART"

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

View Source
const SAVEPOINT = 57553
View Source
const SCONST = 57347
View Source
const SEARCH = 57554
View Source
const SECOND = 57555
View Source
const SELECT = 57556
View Source
const SERIAL = 57557
View Source
const SERIALIZABLE = 57558
View Source
const SESSION = 57559
View Source
const SESSION_USER = 57560
View Source
const SET = 57561
View Source
const SHOW = 57562
View Source
const SIMILAR = 57563
View Source
const SIMPLE = 57564
View Source
const SMALLINT = 57565
View Source
const SMALLSERIAL = 57566
View Source
const SNAPSHOT = 57567
View Source
const SOME = 57568
View Source
const SQL = 57569
View Source
const START = 57570
View Source
const STORING = 57573
View Source
const STRICT = 57571
View Source
const STRING = 57572
View Source
const SUBSTRING = 57574
View Source
const SYMMETRIC = 57575
View Source
const SYSTEM = 57576
View Source
const TABLE = 57577
View Source
const TABLES = 57578
View Source
const TEXT = 57579
View Source
const THEN = 57580
View Source
const TIME = 57581
View Source
const TIMESTAMP = 57582
View Source
const TIMESTAMPTZ = 57583
View Source
const TO = 57584
View Source
const TRAILING = 57585
View Source
const TRANSACTION = 57586
View Source
const TREAT = 57587
View Source
const TRIM = 57588
View Source
const TRUE = 57589
View Source
const TRUNCATE = 57590
View Source
const TYPE = 57591
View Source
const TYPECAST = 57352
View Source
const UMINUS = 57620
View Source
const UNBOUNDED = 57592
View Source
const UNCOMMITTED = 57593
View Source
const UNION = 57594
View Source
const UNIQUE = 57595
View Source
const UNKNOWN = 57596
View Source
const UPDATE = 57597
View Source
const UPSERT = 57598
View Source
const USER = 57599
View Source
const USING = 57600
View Source
const VALID = 57601
View Source
const VALIDATE = 57602
View Source
const VALUE = 57603
View Source
const VALUES = 57604
View Source
const VARCHAR = 57605
View Source
const VARIADIC = 57606
View Source
const VARYING = 57607
View Source
const WHEN = 57608
View Source
const WHERE = 57609
View Source
const WINDOW = 57610
View Source
const WITH = 57611
View Source
const WITHIN = 57612
View Source
const WITHOUT = 57613
View Source
const WITH_LA = 57617
View Source
const YEAR = 57614
View Source
const ZONE = 57615

Variables

View Source
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{}
)
View Source
var Aggregates = map[string][]Builtin{
	"avg": {
		makeAggBuiltin(TypeInt, TypeDecimal, newAvgAggregate),
		makeAggBuiltin(TypeFloat, TypeFloat, newAvgAggregate),
		makeAggBuiltin(TypeDecimal, TypeDecimal, newAvgAggregate),
	},

	"bool_and": {
		makeAggBuiltin(TypeBool, TypeBool, newBoolAndAggregate),
	},

	"bool_or": {
		makeAggBuiltin(TypeBool, TypeBool, newBoolOrAggregate),
	},

	"count": countImpls(),

	"max": makeAggBuiltins(newMaxAggregate, TypeBool, TypeInt, TypeFloat, TypeDecimal, TypeString, TypeBytes, TypeDate, TypeTimestamp, TypeInterval),
	"min": makeAggBuiltins(newMinAggregate, TypeBool, TypeInt, TypeFloat, TypeDecimal, TypeString, TypeBytes, TypeDate, TypeTimestamp, TypeInterval),

	"sum": {
		makeAggBuiltin(TypeInt, TypeDecimal, newSumAggregate),
		makeAggBuiltin(TypeFloat, TypeFloat, newSumAggregate),
		makeAggBuiltin(TypeDecimal, TypeDecimal, newSumAggregate),
	},

	"variance": {
		makeAggBuiltin(TypeInt, TypeDecimal, newVarianceAggregate),
		makeAggBuiltin(TypeDecimal, TypeDecimal, newVarianceAggregate),
		makeAggBuiltin(TypeFloat, TypeFloat, newVarianceAggregate),
	},

	"stddev": {
		makeAggBuiltin(TypeInt, TypeDecimal, newStddevAggregate),
		makeAggBuiltin(TypeDecimal, TypeDecimal, newStddevAggregate),
		makeAggBuiltin(TypeFloat, TypeFloat, newStddevAggregate),
	},
}

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

View Source
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:   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
		},
	},

	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:   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:  TypeInterval,
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeTimestampTZ,
			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:  TypeInt,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeInt,
			RightType:  TypeDecimal,
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
		BinOp{
			LeftType:   TypeDecimal,
			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
		},
	},

	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:   TypeInterval,
			RightType:  TypeInt,
			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
		},
	},

	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
		},
	},

	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
		},
	},
}

BinOps contains the binary operations indexed by operation type.

View Source
var Builtins = map[string][]Builtin{

	"length": {
		stringBuiltin1(func(s string) (Datum, error) {
			return NewDInt(DInt(utf8.RuneCountInString(s))), nil
		}, TypeInt),
		bytesBuiltin1(func(s string) (Datum, error) {
			return NewDInt(DInt(len(s))), nil
		}, TypeInt),
	},

	"octet_length": {
		stringBuiltin1(func(s string) (Datum, error) {
			return NewDInt(DInt(len(s))), nil
		}, TypeInt),
		bytesBuiltin1(func(s string) (Datum, error) {
			return NewDInt(DInt(len(s))), nil
		}, TypeInt),
	},

	"lower": {stringBuiltin1(func(s string) (Datum, error) {
		return NewDString(strings.ToLower(s)), nil
	}, TypeString)},

	"upper": {stringBuiltin1(func(s string) (Datum, error) {
		return NewDString(strings.ToUpper(s)), nil
	}, TypeString)},

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

	"concat": {
		Builtin{
			Types:      VariadicType{TypeString},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"concat_ws": {
		Builtin{
			Types:      VariadicType{TypeString},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"split_part": {
		Builtin{
			Types:      ArgTypes{TypeString, TypeString, TypeInt},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"repeat": {
		Builtin{
			Types:      ArgTypes{TypeString, TypeInt},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"ascii": {stringBuiltin1(func(s string) (Datum, error) {
		for _, ch := range s {
			return NewDInt(DInt(ch)), nil
		}
		return nil, errEmptyInputString
	}, TypeInt)},

	"md5": {stringBuiltin1(func(s string) (Datum, error) {
		return NewDString(fmt.Sprintf("%x", md5.Sum([]byte(s)))), nil
	}, TypeString)},

	"sha1": {stringBuiltin1(func(s string) (Datum, error) {
		return NewDString(fmt.Sprintf("%x", sha1.Sum([]byte(s)))), nil
	}, TypeString)},

	"sha256": {stringBuiltin1(func(s string) (Datum, error) {
		return NewDString(fmt.Sprintf("%x", sha256.Sum256([]byte(s)))), nil
	}, TypeString)},

	"to_hex": {
		Builtin{
			Types:      ArgTypes{TypeInt},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

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

		return NewDInt(DInt(utf8.RuneCountInString(s[:index]) + 1)), nil
	}, TypeInt)},

	"overlay": {
		Builtin{
			Types:      ArgTypes{TypeString, TypeString, TypeInt},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
		Builtin{
			Types:      ArgTypes{TypeString, TypeString, TypeInt, TypeInt},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"btrim": {
		stringBuiltin2(func(s, chars string) (Datum, error) {
			return NewDString(strings.Trim(s, chars)), nil
		}, TypeString),
		stringBuiltin1(func(s string) (Datum, error) {
			return NewDString(strings.TrimSpace(s)), nil
		}, TypeString),
	},

	"ltrim": {
		stringBuiltin2(func(s, chars string) (Datum, error) {
			return NewDString(strings.TrimLeft(s, chars)), nil
		}, TypeString),
		stringBuiltin1(func(s string) (Datum, error) {
			return NewDString(strings.TrimLeftFunc(s, unicode.IsSpace)), nil
		}, TypeString),
	},

	"rtrim": {
		stringBuiltin2(func(s, chars string) (Datum, error) {
			return NewDString(strings.TrimRight(s, chars)), nil
		}, TypeString),
		stringBuiltin1(func(s string) (Datum, error) {
			return NewDString(strings.TrimRightFunc(s, unicode.IsSpace)), nil
		}, TypeString),
	},

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

	"replace": {stringBuiltin3(func(s, from, to string) (Datum, error) {
		return NewDString(strings.Replace(s, from, to, -1)), nil
	}, TypeString)},

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

		runes := make([]rune, 0, len(s))
		for _, c := range s {
			if t, ok := translation[c]; ok {
				if t != deletionRune {
					runes = append(runes, t)
				}
			} else {
				runes = append(runes, c)
			}
		}
		return NewDString(string(runes)), nil
	}, TypeString)},

	"regexp_extract": {
		Builtin{
			Types:      ArgTypes{TypeString, TypeString},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"regexp_replace": {
		Builtin{
			Types:      ArgTypes{TypeString, TypeString, TypeString},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
		Builtin{
			Types:      ArgTypes{TypeString, TypeString, TypeString, TypeString},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"initcap": {stringBuiltin1(func(s string) (Datum, error) {
		return NewDString(strings.Title(strings.ToLower(s))), nil
	}, TypeString)},

	"left": {
		Builtin{
			Types:      ArgTypes{TypeBytes, TypeInt},
			ReturnType: TypeBytes,
			// contains filtered or unexported fields
		},
		Builtin{
			Types:      ArgTypes{TypeString, TypeInt},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"right": {
		Builtin{
			Types:      ArgTypes{TypeBytes, TypeInt},
			ReturnType: TypeBytes,
			// contains filtered or unexported fields
		},
		Builtin{
			Types:      ArgTypes{TypeString, TypeInt},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"random": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
	},

	"experimental_unique_bytes": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeBytes,
			// contains filtered or unexported fields
		},
	},

	"unique_rowid": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

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

	"greatest": {
		Builtin{
			Types:      AnyType{},
			ReturnType: nil,
			// contains filtered or unexported fields
		},
	},

	"least": {
		Builtin{
			Types:      AnyType{},
			ReturnType: nil,
			// contains filtered or unexported fields
		},
	},

	"age": {
		Builtin{
			Types:      ArgTypes{TypeTimestamp},
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
		Builtin{
			Types:      ArgTypes{TypeTimestamp, TypeTimestamp},
			ReturnType: TypeInterval,
			// contains filtered or unexported fields
		},
	},

	"current_date": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeDate,
			// contains filtered or unexported fields
		},
	},

	"now":                   {txnTSImpl},
	"current_timestamp":     {txnTSImpl},
	"transaction_timestamp": {txnTSImpl},

	"statement_timestamp": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
	},

	"cluster_logical_timestamp": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
	},

	"clock_timestamp": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
	},

	"extract": {
		Builtin{
			Types:      ArgTypes{TypeString, TypeTimestamp},
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	"parse_timestamp_ns": {
		Builtin{
			Types:      ArgTypes{TypeString},
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
	},

	"format_timestamp_ns": {
		Builtin{
			Types:      ArgTypes{TypeTimestamp},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},

	"current_timestamp_ns": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeTimestamp,
			// contains filtered or unexported fields
		},
	},

	"abs": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Abs(x))), nil
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			dd := &DDecimal{}
			dd.Abs(x)
			return dd, nil
		}),
		Builtin{
			Types:      ArgTypes{TypeInt},
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	"acos": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Acos(x))), nil
		}),
	},

	"asin": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Asin(x))), nil
		}),
	},

	"atan": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Atan(x))), nil
		}),
	},

	"atan2": {
		floatBuiltin2(func(x, y float64) (Datum, error) {
			return NewDFloat(DFloat(math.Atan2(x, y))), nil
		}),
	},

	"cbrt": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Cbrt(x))), nil
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			dd := &DDecimal{}
			decimal.Cbrt(&dd.Dec, x, decimal.Precision)
			return dd, nil
		}),
	},

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

	"cos": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Cos(x))), nil
		}),
	},

	"cot": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(1 / math.Tan(x))), nil
		}),
	},

	"degrees": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(180.0 * x / math.Pi)), nil
		}),
	},

	"div": {
		floatBuiltin2(func(x, y float64) (Datum, error) {
			return NewDFloat(DFloat(math.Trunc(x / y))), nil
		}),
		decimalBuiltin2(func(x, y *inf.Dec) (Datum, error) {
			if y.Sign() == 0 {
				return nil, errDivByZero
			}
			dd := &DDecimal{}
			dd.QuoRound(x, y, 0, inf.RoundDown)
			return dd, nil
		}),
	},

	"exp": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Exp(x))), nil
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			dd := &DDecimal{}
			decimal.Exp(&dd.Dec, x, decimal.Precision)
			return dd, nil
		}),
	},

	"floor": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Floor(x))), nil
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			dd := &DDecimal{}
			dd.Round(x, 0, inf.RoundFloor)
			return dd, nil
		}),
	},

	"ln": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Log(x))), nil
		}),
		decimalLogFn(decimal.Log),
	},

	"log": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Log10(x))), nil
		}),
		decimalLogFn(decimal.Log10),
	},

	"mod": {
		floatBuiltin2(func(x, y float64) (Datum, error) {
			return NewDFloat(DFloat(math.Mod(x, y))), nil
		}),
		decimalBuiltin2(func(x, y *inf.Dec) (Datum, error) {
			if y.Sign() == 0 {
				return nil, errZeroModulus
			}
			dd := &DDecimal{}
			decimal.Mod(&dd.Dec, x, y)
			return dd, nil
		}),
		Builtin{
			Types:      ArgTypes{TypeInt, TypeInt},
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	"pi": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
	},

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

	"radians": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(x * math.Pi / 180.0)), nil
		}),
	},

	"round": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return round(x, 0)
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			dd := &DDecimal{}
			dd.Round(x, 0, inf.RoundHalfUp)
			return dd, nil
		}),
		Builtin{
			Types:      ArgTypes{TypeFloat, TypeInt},
			ReturnType: TypeFloat,
			// contains filtered or unexported fields
		},
		Builtin{
			Types:      ArgTypes{TypeDecimal, TypeInt},
			ReturnType: TypeDecimal,
			// contains filtered or unexported fields
		},
	},

	"sin": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Sin(x))), nil
		}),
	},

	"sign": {
		floatBuiltin1(func(x float64) (Datum, error) {
			switch {
			case x < 0:
				return NewDFloat(-1), nil
			case x == 0:
				return NewDFloat(0), nil
			}
			return NewDFloat(1), nil
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			return NewDFloat(DFloat(x.Sign())), nil
		}),
		Builtin{
			Types:      ArgTypes{TypeInt},
			ReturnType: TypeInt,
			// contains filtered or unexported fields
		},
	},

	"sqrt": {
		floatBuiltin1(func(x float64) (Datum, error) {
			if x < 0 {
				return nil, errSqrtOfNegNumber
			}
			return NewDFloat(DFloat(math.Sqrt(x))), nil
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			if x.Sign() < 0 {
				return nil, errSqrtOfNegNumber
			}
			dd := &DDecimal{}
			decimal.Sqrt(&dd.Dec, x, decimal.Precision)
			return dd, nil
		}),
	},

	"tan": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Tan(x))), nil
		}),
	},

	"trunc": {
		floatBuiltin1(func(x float64) (Datum, error) {
			return NewDFloat(DFloat(math.Trunc(x))), nil
		}),
		decimalBuiltin1(func(x *inf.Dec) (Datum, error) {
			dd := &DDecimal{}
			dd.Round(x, 0, inf.RoundDown)
			return dd, nil
		}),
	},
	"version": {
		Builtin{
			Types:      ArgTypes{},
			ReturnType: TypeString,
			// contains filtered or unexported fields
		},
	},
}

Builtins contains the built-in functions indexed by name.

View Source
var CmpOps = map[ComparisonOperator]cmpOpOverload{
	EQ: {
		CmpOp{
			LeftType:  TypeString,
			RightType: TypeString,
			// 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:  TypeInterval,
			RightType: TypeInterval,
			// 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:  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:  TypeInterval,
			RightType: TypeInterval,
			// 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:  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:  TypeInterval,
			RightType: TypeInterval,
			// 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(TypeBytes),
		makeEvalTupleIn(TypeDate),
		makeEvalTupleIn(TypeTimestamp),
		makeEvalTupleIn(TypeTimestampTZ),
		makeEvalTupleIn(TypeInterval),
		makeEvalTupleIn(TypeTuple),
	},

	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.

View Source
var NoTypePreference = Datum(nil)

NoTypePreference can be provided to TypeCheck's desired type parameter to indicate that the caller of the function has no preference on the type of the resulting TypedExpr.

View Source
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
		},
	},

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

UnaryOps contains the unary operations indexed by operation type.

Functions

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.

func FindEqualComparisonFunction

func FindEqualComparisonFunction(leftType, rightType Datum) (func(*EvalContext, Datum, Datum) (DBool, 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 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 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 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.

Types

type AggregateFunc

type AggregateFunc interface {
	Add(Datum) error
	Result() (Datum, error)
}

AggregateFunc accumulates the result of a some function of a Datum.

func NewIdentAggregate

func NewIdentAggregate() 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
	As    AliasClause
	AsOf  AsOfClause
}

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 AlterTable

type AlterTable struct {
	IfExists bool
	Table    *QualifiedName
	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
}

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

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableDropNotNull) String

func (n *AlterTableDropNotNull) String() string

type AlterTableSetDefault

type AlterTableSetDefault struct {
	Column  string
	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() string

GetColumn implements the ColumnMutationCmd interface.

func (*AlterTableSetDefault) String

func (n *AlterTableSetDefault) String() string

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

func (ta AndExpr) ReturnType() Datum

func (*AndExpr) String

func (node *AndExpr) String() string

func (*AndExpr) TypeCheck

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

AnnotateTypeExpr represents a ANNOTATE_TYPE(expr, type) expression.

func (*AnnotateTypeExpr) Eval

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

Eval implements the TypedExpr interface.

func (*AnnotateTypeExpr) Format

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

Format implements the NodeFormatter interface.

func (AnnotateTypeExpr) ReturnType

func (ta AnnotateTypeExpr) ReturnType() Datum

func (*AnnotateTypeExpr) String

func (node *AnnotateTypeExpr) String() string

func (*AnnotateTypeExpr) TypeCheck

func (expr *AnnotateTypeExpr) TypeCheck(ctx *SemaContext, desired Datum) (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 AnyType

type AnyType struct{}

AnyType is a typeList implementation that accepts any arguments.

type ArgTypes

type ArgTypes []Datum

ArgTypes is a typeList implementation that accepts a specific number of argument types.

type Array

type Array struct {
	Exprs Exprs
}

Array represents an array constructor.

func (*Array) Format

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

Format implements the NodeFormatter interface.

func (*Array) String

func (node *Array) String() string

func (*Array) TypeCheck

func (expr *Array) TypeCheck(_ *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Array) Walk

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

Walk implements the Expr interface.

type ArrayIndirection

type ArrayIndirection struct {
	Begin Expr
	End   Expr
}

ArrayIndirection represents "[<begin>:<end>]" in an indirection expression.

func (*ArrayIndirection) Format

func (a *ArrayIndirection) 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 BeginTransaction

type BeginTransaction struct {
	Isolation    IsolationLevel
	UserPriority UserPriority
}

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   Datum
	RightType  Datum
	ReturnType Datum
	// 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) ReturnType

func (ta BinaryExpr) ReturnType() Datum

func (*BinaryExpr) String

func (node *BinaryExpr) String() string

func (*BinaryExpr) TypeCheck

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

	AggregateFunc func() AggregateFunc
	// 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).

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

func (ta CaseExpr) ReturnType() Datum

func (*CaseExpr) String

func (node *CaseExpr) String() string

func (*CaseExpr) TypeCheck

func (expr *CaseExpr) TypeCheck(ctx *SemaContext, desired Datum) (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 ColumnType
	// 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) ReturnType

func (ta CastExpr) ReturnType() Datum

func (*CastExpr) String

func (node *CastExpr) String() string

func (*CastExpr) TypeCheck

func (expr *CastExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CastExpr) Walk

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

Walk implements the Expr interface.

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  Datum
	RightType Datum
	// 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) ReturnType

func (ta CoalesceExpr) ReturnType() Datum

func (*CoalesceExpr) String

func (node *CoalesceExpr) String() string

func (*CoalesceExpr) TypeCheck

func (expr *CoalesceExpr) TypeCheck(ctx *SemaContext, desired Datum) (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 ColumnCheckConstraint

type ColumnCheckConstraint struct {
	Expr Expr
}

ColumnCheckConstraint represents either a check on a column.

type ColumnDefault

type ColumnDefault struct {
	Expr Expr
}

ColumnDefault represents a DEFAULT clause for a column.

type ColumnFKConstraint

type ColumnFKConstraint struct {
	Table *QualifiedName
	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 ColumnMutationCmd

type ColumnMutationCmd interface {
	AlterTableCmd
	GetColumn() string
}

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
	}
	CheckExpr struct {
		Expr           Expr
		ConstraintName Name
	}
	References struct {
		Table          *QualifiedName
		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.

type ColumnType

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

ColumnType represents a type in a column definition.

func DatumTypeToColumnType

func DatumTypeToColumnType(d Datum) (ColumnType, error)

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

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

func (ta ComparisonExpr) ReturnType() Datum

func (*ComparisonExpr) String

func (node *ComparisonExpr) String() string

func (*ComparisonExpr) TypeCheck

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

ComparisonExpr.Operator

func (ComparisonOperator) String

func (i ComparisonOperator) String() string

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() []Datum
	// 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, Datum) (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 CreateDatabase

type CreateDatabase struct {
	IfNotExists bool
	Name        Name
	Encoding    *StrVal
}

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       *QualifiedName
	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       *QualifiedName
	Interleave  *InterleaveDef
	Defs        TableDefs
}

CreateTable represents a CREATE TABLE statement.

func (*CreateTable) Format

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

Format implements the NodeFormatter interface.

func (*CreateTable) StatementTag

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

func (d *DBool) Compare(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) HasNext

func (*DBool) HasNext() bool

HasNext implements the Datum interface.

func (*DBool) HasPrev

func (*DBool) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DBool) Prev

func (*DBool) Prev() Datum

Prev implements the Datum interface.

func (*DBool) ReturnType

func (*DBool) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DBool) String

func (node *DBool) String() string

func (*DBool) Type

func (*DBool) Type() string

Type implements the Datum interface.

func (*DBool) TypeCheck

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

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

func (*DBool) TypeEqual

func (d *DBool) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

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 (*DBytes) Compare

func (d *DBytes) Compare(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) HasNext

func (*DBytes) HasNext() bool

HasNext implements the Datum interface.

func (*DBytes) HasPrev

func (*DBytes) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DBytes) Prev

func (d *DBytes) Prev() Datum

Prev implements the Datum interface.

func (*DBytes) ReturnType

func (d *DBytes) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DBytes) String

func (node *DBytes) String() string

func (*DBytes) Type

func (*DBytes) Type() string

Type implements the Datum interface.

func (*DBytes) TypeCheck

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

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

func (*DBytes) TypeEqual

func (d *DBytes) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (*DBytes) Walk

func (expr *DBytes) 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) Compare

func (d *DDate) Compare(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) HasNext

func (*DDate) HasNext() bool

HasNext implements the Datum interface.

func (*DDate) HasPrev

func (*DDate) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DDate) Prev

func (d *DDate) Prev() Datum

Prev implements the Datum interface.

func (*DDate) ReturnType

func (*DDate) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DDate) String

func (node *DDate) String() string

func (*DDate) Type

func (*DDate) Type() string

Type implements the Datum interface.

func (*DDate) TypeCheck

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

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

func (*DDate) TypeEqual

func (d *DDate) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (*DDate) Walk

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

Walk implements the Expr interface.

type DDecimal

type DDecimal struct {
	inf.Dec
}

DDecimal is the decimal Datum.

var DecimalOne DDecimal

DecimalOne represents the constant 1 as DECIMAL.

var DecimalZero DDecimal

DecimalZero represents the constant 0 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 (*DDecimal) Compare

func (d *DDecimal) Compare(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) HasNext

func (*DDecimal) HasNext() bool

HasNext implements the Datum interface.

func (*DDecimal) HasPrev

func (*DDecimal) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DDecimal) Prev

func (d *DDecimal) Prev() Datum

Prev implements the Datum interface.

func (*DDecimal) ReturnType

func (d *DDecimal) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DDecimal) String

func (node *DDecimal) String() string

func (*DDecimal) Type

func (*DDecimal) Type() string

Type implements the Datum interface.

func (*DDecimal) TypeCheck

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

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

func (*DDecimal) TypeEqual

func (d *DDecimal) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

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

func (d *DFloat) Compare(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) HasNext

func (*DFloat) HasNext() bool

HasNext implements the Datum interface.

func (*DFloat) HasPrev

func (*DFloat) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DFloat) Prev

func (d *DFloat) Prev() Datum

Prev implements the Datum interface.

func (*DFloat) ReturnType

func (*DFloat) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DFloat) String

func (node *DFloat) String() string

func (*DFloat) Type

func (*DFloat) Type() string

Type implements the Datum interface.

func (*DFloat) TypeCheck

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

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

func (*DFloat) TypeEqual

func (d *DFloat) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

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

func (d *DInt) Compare(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) HasNext

func (*DInt) HasNext() bool

HasNext implements the Datum interface.

func (*DInt) HasPrev

func (*DInt) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DInt) Prev

func (d *DInt) Prev() Datum

Prev implements the Datum interface.

func (*DInt) ReturnType

func (*DInt) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DInt) String

func (node *DInt) String() string

func (*DInt) Type

func (*DInt) Type() string

Type implements the Datum interface.

func (*DInt) TypeCheck

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

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

func (*DInt) TypeEqual

func (d *DInt) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

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 (*DInterval) Compare

func (d *DInterval) Compare(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) HasNext

func (*DInterval) HasNext() bool

HasNext implements the Datum interface.

func (*DInterval) HasPrev

func (*DInterval) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DInterval) Prev

func (d *DInterval) Prev() Datum

Prev implements the Datum interface.

func (*DInterval) ReturnType

func (d *DInterval) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DInterval) String

func (node *DInterval) String() string

func (*DInterval) Type

func (*DInterval) Type() string

Type implements the Datum interface.

func (*DInterval) TypeCheck

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

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

func (*DInterval) TypeEqual

func (d *DInterval) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (*DInterval) Walk

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

Walk implements the Expr interface.

type DPlaceholder

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

DPlaceholder is the named placeholder Datum.

func (*DPlaceholder) Compare

func (d *DPlaceholder) Compare(other Datum) int

Compare implements the Datum interface.

func (*DPlaceholder) Eval

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

Eval implements the TypedExpr interface.

func (*DPlaceholder) Format

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

Format implements the NodeFormatter interface.

func (*DPlaceholder) HasNext

func (*DPlaceholder) HasNext() bool

HasNext implements the Datum interface.

func (*DPlaceholder) HasPrev

func (*DPlaceholder) HasPrev() bool

HasPrev implements the Datum interface.

func (*DPlaceholder) IsMax

func (*DPlaceholder) IsMax() bool

IsMax implements the Datum interface.

func (*DPlaceholder) IsMin

func (*DPlaceholder) IsMin() bool

IsMin implements the Datum interface.

func (*DPlaceholder) Name

func (d *DPlaceholder) Name() string

Name gives access to the placeholder's name to other packages.

func (*DPlaceholder) Next

func (d *DPlaceholder) Next() Datum

Next implements the Datum interface.

func (*DPlaceholder) Prev

func (d *DPlaceholder) Prev() Datum

Prev implements the Datum interface.

func (*DPlaceholder) ReturnType

func (d *DPlaceholder) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DPlaceholder) String

func (node *DPlaceholder) String() string

func (*DPlaceholder) Type

func (*DPlaceholder) Type() string

Type implements the Datum interface.

func (*DPlaceholder) TypeCheck

func (d *DPlaceholder) TypeCheck(_ *SemaContext, desired Datum) (TypedExpr, error)

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

func (*DPlaceholder) TypeEqual

func (d *DPlaceholder) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (*DPlaceholder) Variable

func (*DPlaceholder) Variable()

Variable implements the VariableExpr interface.

func (*DPlaceholder) Walk

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

Walk implements the Expr interface.

type DString

type DString string

DString is the string Datum.

func NewDString

func NewDString(d string) *DString

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

func (*DString) Compare

func (d *DString) Compare(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) HasNext

func (*DString) HasNext() bool

HasNext implements the Datum interface.

func (*DString) HasPrev

func (*DString) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DString) Prev

func (d *DString) Prev() Datum

Prev implements the Datum interface.

func (*DString) ReturnType

func (*DString) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DString) String

func (node *DString) String() string

func (*DString) Type

func (*DString) Type() string

Type implements the Datum interface.

func (*DString) TypeCheck

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

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

func (*DString) TypeEqual

func (d *DString) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (*DString) Walk

func (expr *DString) 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, loc *time.Location, precision time.Duration) (*DTimestamp, error)

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

func (*DTimestamp) Compare

func (d *DTimestamp) Compare(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) HasNext

func (*DTimestamp) HasNext() bool

HasNext implements the Datum interface.

func (*DTimestamp) HasPrev

func (*DTimestamp) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DTimestamp) Prev

func (d *DTimestamp) Prev() Datum

Prev implements the Datum interface.

func (*DTimestamp) ReturnType

func (*DTimestamp) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DTimestamp) String

func (node *DTimestamp) String() string

func (*DTimestamp) Type

func (*DTimestamp) Type() string

Type implements the Datum interface.

func (*DTimestamp) TypeCheck

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

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

func (*DTimestamp) TypeEqual

func (d *DTimestamp) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

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

func (d *DTimestampTZ) Compare(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) HasNext

func (d *DTimestampTZ) HasNext() bool

HasNext implements the Datum interface.

func (*DTimestampTZ) HasPrev

func (d *DTimestampTZ) HasPrev() bool

HasPrev implements the Datum 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

Next implements the Datum interface.

func (*DTimestampTZ) Prev

func (d *DTimestampTZ) Prev() Datum

Prev implements the Datum interface.

func (*DTimestampTZ) ReturnType

func (*DTimestampTZ) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DTimestampTZ) String

func (node *DTimestampTZ) String() string

func (*DTimestampTZ) Type

func (d *DTimestampTZ) Type() string

Type implements the Datum interface.

func (*DTimestampTZ) TypeCheck

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

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

func (*DTimestampTZ) TypeEqual

func (d *DTimestampTZ) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (*DTimestampTZ) Walk

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

Walk implements the Expr interface.

type DTuple

type DTuple []Datum

DTuple is the tuple Datum.

func (*DTuple) Compare

func (d *DTuple) Compare(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) HasNext

func (d *DTuple) HasNext() bool

HasNext implements the Datum interface.

func (*DTuple) HasPrev

func (d *DTuple) HasPrev() bool

HasPrev implements the Datum interface.

func (*DTuple) IsMax

func (*DTuple) IsMax() bool

IsMax implements the Datum interface.

func (*DTuple) IsMin

func (*DTuple) IsMin() bool

IsMin implements the Datum interface.

func (*DTuple) Len

func (d *DTuple) Len() int

func (*DTuple) Less

func (d *DTuple) Less(i, j int) bool

func (*DTuple) Next

func (d *DTuple) Next() Datum

Next implements the Datum interface.

func (*DTuple) Normalize

func (d *DTuple) Normalize()

Normalize sorts and uniques the datum tuple.

func (*DTuple) Prev

func (d *DTuple) Prev() Datum

Prev implements the Datum interface.

func (*DTuple) ReturnType

func (d *DTuple) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*DTuple) SortedDifference

func (d *DTuple) SortedDifference(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) Swap

func (d *DTuple) Swap(i, j int)

func (*DTuple) Type

func (*DTuple) Type() string

Type implements the Datum interface.

func (*DTuple) TypeCheck

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

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

func (*DTuple) TypeEqual

func (d *DTuple) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (*DTuple) Walk

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

Walk implements the Expr interface.

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
	// Type returns the (user-friendly) name of the type.
	Type() string
	// TypeEqual determines if the receiver and the other Datum have the same
	// type or not. This method should be used for asserting the type of all
	// Datum, with the exception of DNull, where it is safe/encouraged to perform
	// a direct equivalence check.
	TypeEqual(other Datum) 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.
	// TODO(nvanbenschoten) Should we look into merging this with cmpOps?
	Compare(other Datum) int
	// HasPrev specifies if Prev() can be used to compute a previous value for
	// a datum. For example, DBytes doesn't support it (the previous for BB is BAZZZ..).
	HasPrev() bool
	// Prev returns the previous datum. If the receiver is "b" and the returned datum
	// is "a", then "a < b" and no other datum will compare such that "a < c <
	// b".
	// The return value is undefined if `IsMin()`.
	Prev() Datum
	// HasNext specifies if Next() can be used to compute a next value for a
	// datum. For example, DDecimal doesn't support it (the next for 1.0 is 1.00..1).
	HasNext() bool
	// Next returns the next datum. If the receiver is "a" and the returned datum
	// is "b", then "a < b" and no other datum will compare such that "a < c <
	// b".
	// The return value is undefined if `IsMax()`.
	Next() Datum
	// IsMax returns true if the datum is equal to the maximum value the datum
	// type can hold.
	IsMax() bool
	// IsMin returns true if the datum is equal to the minimum value the datum
	// type can hold.
	IsMin() bool
}

A Datum holds either a bool, int64, float64, string or []Datum.

var (
	// TypeBool is the type of a DBool.
	TypeBool Datum = DBoolFalse
	// TypeInt is the type of a DInt.
	TypeInt Datum = NewDInt(0)
	// TypeFloat is the type of a DFloat.
	TypeFloat Datum = NewDFloat(0)
	// TypeDecimal is the type of a DDecimal.
	TypeDecimal Datum = &DDecimal{}
	// TypeString is the type of a DString.
	TypeString Datum = NewDString("")
	// TypeBytes is the type of a DBytes.
	TypeBytes Datum = NewDBytes("")
	// TypeDate is the type of a DDate.
	TypeDate Datum = NewDDate(0)
	// TypeTimestamp is the type of a DTimestamp.
	TypeTimestamp Datum = &DTimestamp{}
	// TypeTimestampTZ is the type of a DTimestamp.
	TypeTimestampTZ Datum = &DTimestampTZ{}
	// TypeInterval is the type of a DInterval.
	TypeInterval Datum = &DInterval{}
	// TypeTuple is the type of a DTuple.
	TypeTuple Datum = &DTuple{}
)

type Deallocate

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

Deallocate represents a DEALLOCATE statement.

func (*Deallocate) Format

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

Format implements the NodeFormatter interface.

func (*Deallocate) StatementTag

func (n *Deallocate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Deallocate) StatementType

func (*Deallocate) StatementType() StatementType

StatementType implements the Statement interface.

func (*Deallocate) String

func (n *Deallocate) String() string

type DecimalColType

type DecimalColType struct {
	Name  string
	Prec  int
	Scale int
}

DecimalColType represents a DECIMAL or NUMERIC type.

func (*DecimalColType) Format

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

Format implements the NodeFormatter interface.

func (*DecimalColType) String

func (node *DecimalColType) String() string

type DefaultVal

type DefaultVal struct{}

DefaultVal represents the DEFAULT expression.

func (DefaultVal) Eval

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

Eval implements the TypedExpr interface.

func (DefaultVal) Format

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

Format implements the NodeFormatter interface.

func (DefaultVal) ReturnType

func (DefaultVal) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (DefaultVal) String

func (node DefaultVal) String() string

func (DefaultVal) TypeCheck

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

TypeCheck implements the Expr interface.

func (DefaultVal) Walk

func (expr DefaultVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type Delete

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

Delete represents a DELETE statement.

func (*Delete) CopyNode

func (stmt *Delete) CopyNode() *Delete

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

func (*Delete) Format

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

Format implements the NodeFormatter interface.

func (*Delete) StatementTag

func (*Delete) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Delete) StatementType

func (n *Delete) StatementType() StatementType

StatementType implements the Statement interface.

func (*Delete) String

func (n *Delete) String() string

func (*Delete) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type Direction

type Direction int

Direction for ordering results.

const (
	DefaultDirection Direction = iota
	Ascending
	Descending
)

Direction values.

func (Direction) String

func (d Direction) String() string

type DropBehavior

type DropBehavior int

DropBehavior represents options for dropping schema elements.

const (
	DropDefault DropBehavior = iota
	DropRestrict
	DropCascade
)

DropBehavior values.

func (DropBehavior) String

func (d DropBehavior) String() string

type DropDatabase

type DropDatabase struct {
	Name     Name
	IfExists bool
}

DropDatabase represents a DROP DATABASE statement.

func (*DropDatabase) Format

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

Format implements the NodeFormatter interface.

func (*DropDatabase) StatementTag

func (*DropDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropDatabase) StatementType

func (*DropDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropDatabase) String

func (n *DropDatabase) String() string

type DropIndex

type DropIndex struct {
	IndexList    TableNameWithIndexList
	IfExists     bool
	DropBehavior DropBehavior
}

DropIndex represents a DROP INDEX statement.

func (*DropIndex) Format

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

Format implements the NodeFormatter interface.

func (*DropIndex) StatementTag

func (*DropIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropIndex) StatementType

func (*DropIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropIndex) String

func (n *DropIndex) String() string

type DropTable

type DropTable struct {
	Names        QualifiedNames
	IfExists     bool
	DropBehavior DropBehavior
}

DropTable represents a DROP TABLE statement.

func (*DropTable) Format

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

Format implements the NodeFormatter interface.

func (*DropTable) StatementTag

func (*DropTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropTable) StatementType

func (*DropTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropTable) String

func (n *DropTable) String() string

type EvalContext

type EvalContext struct {
	NodeID roachpb.NodeID

	// Location references the *Location on the current Session.
	Location **time.Location

	ReCache *RegexpCache

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

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

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

func (*EvalContext) GetClusterTimestamp

func (ctx *EvalContext) GetClusterTimestamp() *DDecimal

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

func (*EvalContext) GetLocation

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

GetLocation returns the session timezone.

func (*EvalContext) GetStmtTimestamp

func (ctx *EvalContext) GetStmtTimestamp() *DTimestamp

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

func (*EvalContext) GetTxnTimestamp

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

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

func (*EvalContext) NormalizeExpr

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

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

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

func (*EvalContext) SetClusterTimestamp

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

SetClusterTimestamp sets the corresponding timestamp in the EvalContext.

func (*EvalContext) SetStmtTimestamp

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

SetStmtTimestamp sets the corresponding timestamp in the EvalContext.

func (*EvalContext) SetTxnTimestamp

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

SetTxnTimestamp sets the corresponding timestamp in the EvalContext.

type Execute

type Execute struct {
	Name   Name
	Params Exprs
}

Execute represents an EXECUTE statement.

func (*Execute) Format

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

Format implements the NodeFormatter interface.

func (*Execute) StatementTag

func (*Execute) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Execute) StatementType

func (*Execute) StatementType() StatementType

StatementType implements the Statement interface.

func (*Execute) String

func (n *Execute) String() string

type ExistsExpr

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

ExistsExpr represents an EXISTS expression.

func (*ExistsExpr) Eval

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

Eval implements the TypedExpr interface.

func (*ExistsExpr) Format

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

Format implements the NodeFormatter interface.

func (ExistsExpr) ReturnType

func (ta ExistsExpr) ReturnType() Datum

func (*ExistsExpr) String

func (node *ExistsExpr) String() string

func (*ExistsExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*ExistsExpr) Walk

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

Walk implements the Expr interface.

type Explain

type Explain struct {
	Options   []string
	Statement Statement
}

Explain represents an EXPLAIN statement.

func (*Explain) CopyNode

func (stmt *Explain) CopyNode() *Explain

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

func (*Explain) Format

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

Format implements the NodeFormatter interface.

func (*Explain) StatementTag

func (*Explain) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Explain) StatementType

func (*Explain) StatementType() StatementType

StatementType implements the Statement interface.

func (*Explain) String

func (n *Explain) String() string

func (*Explain) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type Expr

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

Expr represents an expression.

func ParseExprTraditional

func ParseExprTraditional(sql string) (Expr, error)

ParseExprTraditional is a short-hand for parseExprs(Traditional, []string{sql})

func SimpleVisit

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

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

func StripParens

func StripParens(expr Expr) Expr

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

 1   -> 1
(1)  -> 1

((1)) -> 1

func WalkExpr

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

WalkExpr traverses the nodes in an expression.

type Exprs

type Exprs []Expr

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

func ParseExprsTraditional

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

ParseExprsTraditional is a short-hand for parseExprs(Traditional, sql)

func (Exprs) Format

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

Format implements the NodeFormatter interface.

func (Exprs) String

func (node Exprs) String() string

type FamilyElem

type FamilyElem struct {
	Column Name
}

FamilyElem represents a column in a FAMILY constraint.

func (FamilyElem) Format

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

Format implements the NodeFormatter interface.

type FamilyElemList

type FamilyElemList []FamilyElem

FamilyElemList is list of FamilyElem.

func (FamilyElemList) Format

func (l FamilyElemList) Format(buf *bytes.Buffer, f FmtFlags)

Format pretty-prints the contained names separated by commas. Format implements the NodeFormatter interface.

type FamilyTableDef

type FamilyTableDef struct {
	Name    Name
	Columns FamilyElemList
}

FamilyTableDef represents a family definition within a CREATE TABLE statement.

func (*FamilyTableDef) Format

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

Format implements the NodeFormatter interface.

type FloatColType

type FloatColType struct {
	Name string
	Prec int
}

FloatColType represents a REAL, DOUBLE or FLOAT type.

func (*FloatColType) Format

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

Format implements the NodeFormatter interface.

func (*FloatColType) String

func (node *FloatColType) String() string

type FmtFlags

type FmtFlags *fmtFlags

FmtFlags enables conditional formatting in the pretty-printer.

var FmtQualify FmtFlags = &fmtFlags{showTableAliases: true}

FmtQualify instructs the pretty-printer to qualify qnames with the table name.

var FmtShowTypes FmtFlags = &fmtFlags{showTypes: true}

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

var FmtSimple FmtFlags = &fmtFlags{showTypes: false}

FmtSimple instructs the pretty-printer to produce a straightforward representation, ideally using SQL syntax that makes prettyprint+parse idempotent.

type FuncExpr

type FuncExpr struct {
	Name  *QualifiedName
	Type  funcType
	Exprs Exprs
	// contains filtered or unexported fields
}

FuncExpr represents a function call.

func (*FuncExpr) CopyNode

func (expr *FuncExpr) CopyNode() *FuncExpr

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

func (*FuncExpr) Eval

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

Eval implements the TypedExpr interface.

func (*FuncExpr) Format

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

Format implements the NodeFormatter interface.

func (FuncExpr) ReturnType

func (ta FuncExpr) ReturnType() Datum

func (*FuncExpr) String

func (node *FuncExpr) String() string

func (*FuncExpr) TypeCheck

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

TypeCheck implements the Expr interface.

func (*FuncExpr) Walk

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

Walk implements the Expr interface.

type Grant

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

Grant represents a GRANT statement.

func (*Grant) Format

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

Format implements the NodeFormatter interface.

func (*Grant) StatementTag

func (*Grant) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Grant) StatementType

func (*Grant) StatementType() StatementType

StatementType implements the Statement interface.

func (*Grant) String

func (n *Grant) String() string

type GroupBy

type GroupBy []Expr

GroupBy represents a GROUP BY clause.

func (GroupBy) Format

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

Format implements the NodeFormatter interface.

type IfExpr

type IfExpr struct {
	Cond Expr
	True Expr
	Else Expr
	// contains filtered or unexported fields
}

IfExpr represents an IF expression.

func (*IfExpr) Eval

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

Eval implements the TypedExpr interface.

func (*IfExpr) Format

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

Format implements the NodeFormatter interface.

func (IfExpr) ReturnType

func (ta IfExpr) ReturnType() Datum

func (*IfExpr) String

func (node *IfExpr) String() string

func (*IfExpr) TypeCheck

func (expr *IfExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IfExpr) TypedCondExpr

func (node *IfExpr) TypedCondExpr() TypedExpr

TypedCondExpr returns the IfExpr's Cond expression as a TypedExpr.

func (*IfExpr) TypedElseExpr

func (node *IfExpr) TypedElseExpr() TypedExpr

TypedElseExpr returns the IfExpr's Else expression as a TypedExpr.

func (*IfExpr) TypedTrueExpr

func (node *IfExpr) TypedTrueExpr() TypedExpr

TypedTrueExpr returns the IfExpr's True expression as a TypedExpr.

func (*IfExpr) Walk

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

Walk implements the Expr interface.

type IndexElem

type IndexElem struct {
	Column    Name
	Direction Direction
}

IndexElem represents a column with a direction in a CREATE INDEX statement.

func (IndexElem) Format

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

Format implements the NodeFormatter interface.

type IndexElemList

type IndexElemList []IndexElem

IndexElemList is list of IndexElem.

func NameListToIndexElems

func NameListToIndexElems(lst NameList) IndexElemList

NameListToIndexElems converts a NameList to an IndexElemList with all members using the `DefaultDirection`.

func (IndexElemList) Format

func (l IndexElemList) Format(buf *bytes.Buffer, f FmtFlags)

Format pretty-prints the contained names separated by commas. Format implements the NodeFormatter interface.

type IndexHints

type IndexHints struct {
	Index       Name
	NoIndexJoin bool
}

IndexHints represents "@<index_name>" or "@{param[,param]}" where param is one of:

  • FORCE_INDEX=<index_name>
  • NO_INDEX_JOIN

It is used optionally after a table name in SELECT statements.

func (*IndexHints) Format

func (n *IndexHints) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type IndexTableDef

type IndexTableDef struct {
	Name       Name
	Columns    IndexElemList
	Storing    NameList
	Interleave *InterleaveDef
}

IndexTableDef represents an index definition within a CREATE TABLE statement.

func (*IndexTableDef) Format

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

Format implements the NodeFormatter interface.

type IndexedVar

type IndexedVar struct {
	Idx int
	// contains filtered or unexported fields
}

IndexedVar is a VariableExpr that can be used as a leaf in expressions; it represents a dynamic value. It defers calls to TypeCheck, Eval, String to an IndexedVarContainer.

func (*IndexedVar) Eval

func (v *IndexedVar) Eval(ctx *EvalContext) (Datum, error)

Eval is part of the TypedExpr interface.

func (*IndexedVar) Format

func (v *IndexedVar) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*IndexedVar) ReturnType

func (v *IndexedVar) ReturnType() Datum

ReturnType is part of the TypedExpr interface.

func (*IndexedVar) String

func (node *IndexedVar) String() string

func (*IndexedVar) TypeCheck

func (v *IndexedVar) TypeCheck(_ *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck is part of the Expr interface.

func (*IndexedVar) Variable

func (*IndexedVar) Variable()

Variable is a dummy function part of the VariableExpr interface.

func (*IndexedVar) Walk

func (v *IndexedVar) Walk(_ Visitor) Expr

Walk is part of the Expr interface.

type IndexedVarContainer

type IndexedVarContainer interface {
	IndexedVarEval(idx int, ctx *EvalContext) (Datum, error)
	IndexedVarReturnType(idx int) Datum
	IndexedVarString(idx int) string
}

IndexedVarContainer provides the implementation of TypeCheck, Eval, and String for IndexedVars.

type IndexedVarHelper

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

IndexedVarHelper is a structure that helps with initialization of IndexVars.

func MakeIndexedVarHelper

func MakeIndexedVarHelper(container IndexedVarContainer, numVars int) IndexedVarHelper

MakeIndexedVarHelper initializes an IndexedVarHelper structure.

func (*IndexedVarHelper) IndexedVar

func (h *IndexedVarHelper) IndexedVar(idx int) *IndexedVar

IndexedVar returns an IndexedVar for the given index. The index must be valid.

func (*IndexedVarHelper) IndexedVarUsed

func (h *IndexedVarHelper) IndexedVarUsed(idx int) bool

IndexedVarUsed returns true if IndexedVar() was called for the given index. The index must be valid.

func (*IndexedVarHelper) NumVars

func (h *IndexedVarHelper) NumVars() int

NumVars returns the number of variables the IndexedVarHelper was initialized for.

type Indirection

type Indirection []IndirectionElem

Indirection represents an indirection expression composed of a series of indirection elements.

func (Indirection) Format

func (i Indirection) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type IndirectionElem

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

IndirectionElem is a single element in an indirection expression.

type Insert

type Insert struct {
	Table      TableExpr
	Columns    QualifiedNames
	Rows       *Select
	OnConflict *OnConflict
	Returning  ReturningExprs
}

Insert represents an INSERT statement.

func (*Insert) CopyNode

func (stmt *Insert) CopyNode() *Insert

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

func (*Insert) DefaultValues

func (node *Insert) DefaultValues() bool

DefaultValues returns true iff only default values are being inserted.

func (*Insert) Format

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

Format implements the NodeFormatter interface.

func (*Insert) StatementTag

func (*Insert) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Insert) StatementType

func (n *Insert) StatementType() StatementType

StatementType implements the Statement interface.

func (*Insert) String

func (n *Insert) String() string

func (*Insert) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type IntColType

type IntColType struct {
	Name string
	N    int
}

IntColType represents an INT, INTEGER, SMALLINT or BIGINT type.

func (*IntColType) Format

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

Format implements the NodeFormatter interface.

func (*IntColType) IsSerial

func (node *IntColType) IsSerial() bool

IsSerial returns true when this column should be given a DEFAULT of a unique, incrementing function.

func (*IntColType) String

func (node *IntColType) String() string

type InterleaveDef

type InterleaveDef struct {
	Parent       *QualifiedName
	Fields       []string
	DropBehavior DropBehavior
}

InterleaveDef represents an interleave definition within a CREATE TABLE or CREATE INDEX statement.

func (*InterleaveDef) Format

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

Format implements the NodeFormatter interface.

type IntervalColType

type IntervalColType struct {
}

IntervalColType represents an INTERVAL type

func (*IntervalColType) Format

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

Format implements the NodeFormatter interface.

func (*IntervalColType) String

func (node *IntervalColType) String() string

type IsAggregateVisitor

type IsAggregateVisitor struct {
	Aggregated bool
}

IsAggregateVisitor checks if walked expressions contain aggregate functions.

func (*IsAggregateVisitor) Reset

func (v *IsAggregateVisitor) Reset()

Reset clear the IsAggregateVisitor's internal state.

func (*IsAggregateVisitor) VisitPost

func (*IsAggregateVisitor) VisitPost(expr Expr) Expr

VisitPost satisfies the Visitor interface.

func (*IsAggregateVisitor) VisitPre

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

VisitPre satisfies the Visitor interface.

type IsOfTypeExpr

type IsOfTypeExpr struct {
	Not   bool
	Expr  Expr
	Types []ColumnType
	// contains filtered or unexported fields
}

IsOfTypeExpr represents an IS {,NOT} OF (type_list) expression.

func (*IsOfTypeExpr) Eval

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

Eval implements the TypedExpr interface.

func (*IsOfTypeExpr) Format

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

Format implements the NodeFormatter interface.

func (IsOfTypeExpr) ReturnType

func (ta IsOfTypeExpr) ReturnType() Datum

func (*IsOfTypeExpr) String

func (node *IsOfTypeExpr) String() string

func (*IsOfTypeExpr) TypeCheck

func (expr *IsOfTypeExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IsOfTypeExpr) Walk

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

Walk implements the Expr interface.

type IsolationLevel

type IsolationLevel int

IsolationLevel holds the isolation level for a transaction.

const (
	UnspecifiedIsolation IsolationLevel = iota
	SnapshotIsolation
	SerializableIsolation
)

IsolationLevel values

func (IsolationLevel) String

func (i IsolationLevel) String() string

type JoinCond

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

JoinCond represents a join condition.

type JoinTableExpr

type JoinTableExpr struct {
	Join  string
	Left  TableExpr
	Right TableExpr
	Cond  JoinCond
}

JoinTableExpr represents a TableExpr that's a JOIN operation.

func (*JoinTableExpr) Format

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

Format implements the NodeFormatter interface.

func (*JoinTableExpr) String

func (node *JoinTableExpr) String() string

type Limit

type Limit struct {
	Offset, Count Expr
}

Limit represents a LIMIT clause.

func (*Limit) Format

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

Format implements the NodeFormatter interface.

type MaxAggregate

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

MaxAggregate keeps track of the largest value passed to Add.

func (*MaxAggregate) Add

func (a *MaxAggregate) Add(datum Datum) error

Add sets the max to the larger of the current max or the passed datum.

func (*MaxAggregate) Result

func (a *MaxAggregate) Result() (Datum, error)

Result returns the largest value passed to Add.

type MinAggregate

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

MinAggregate keeps track of the smallest value passed to Add.

func (*MinAggregate) Add

func (a *MinAggregate) Add(datum Datum) error

Add sets the min to the smaller of the current min or the passed datum.

func (*MinAggregate) Result

func (a *MinAggregate) Result() (Datum, error)

Result returns the smallest value passed to Add.

type Name

type Name string

A Name is an SQL identifier.

func (Name) Format

func (n Name) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (Name) String

func (node Name) String() string

type NameIndirection

type NameIndirection Name

NameIndirection represents ".<name>" in an indirection expression.

func (NameIndirection) Format

func (n NameIndirection) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type NameList

type NameList []string

A NameList is a list of identifier. TODO(tschottdorf): would be nicer to have []Name here but unless we want to introduce new types to the grammar, NameList([]string{...}) needs to work.

func (NameList) Format

func (l NameList) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (NameList) String

func (list NameList) String() string

type NamedColumnQualification

type NamedColumnQualification struct {
	Name          Name
	Qualification ColumnQualification
}

NamedColumnQualification wraps a NamedColumnQualification with a name.

type NaturalJoinCond

type NaturalJoinCond struct{}

NaturalJoinCond represents a NATURAL join condition

func (NaturalJoinCond) Format

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

Format implements the NodeFormatter interface.

type NodeFormatter

type NodeFormatter interface {
	// Format performs pretty-printing towards a bytes buffer. The
	// flags argument influences the results.
	Format(buf *bytes.Buffer, flags FmtFlags)
}

NodeFormatter is implemented by nodes that can be pretty-printed.

type NotExpr

type NotExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

NotExpr represents a NOT expression.

func NewTypedNotExpr

func NewTypedNotExpr(expr TypedExpr) *NotExpr

NewTypedNotExpr returns a new NotExpr that is verified to be well-typed.

func (*NotExpr) Eval

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

Eval implements the TypedExpr interface.

func (*NotExpr) Format

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

Format implements the NodeFormatter interface.

func (NotExpr) ReturnType

func (ta NotExpr) ReturnType() Datum

func (*NotExpr) String

func (node *NotExpr) String() string

func (*NotExpr) TypeCheck

func (expr *NotExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*NotExpr) TypedInnerExpr

func (node *NotExpr) TypedInnerExpr() TypedExpr

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

func (*NotExpr) Walk

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

Walk implements the Expr interface.

type NotNullConstraint

type NotNullConstraint struct{}

NotNullConstraint represents NOT NULL on a column.

type NullConstraint

type NullConstraint struct{}

NullConstraint represents NULL on a column.

type NullIfExpr

type NullIfExpr struct {
	Expr1 Expr
	Expr2 Expr
	// contains filtered or unexported fields
}

NullIfExpr represents a NULLIF expression.

func (*NullIfExpr) Eval

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

Eval implements the TypedExpr interface.

func (*NullIfExpr) Format

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

Format implements the NodeFormatter interface.

func (NullIfExpr) ReturnType

func (ta NullIfExpr) ReturnType() Datum

func (*NullIfExpr) String

func (node *NullIfExpr) String() string

func (*NullIfExpr) TypeCheck

func (expr *NullIfExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*NullIfExpr) Walk

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

Walk implements the Expr interface.

type Nullability

type Nullability int

Nullability represents either NULL, NOT NULL or an unspecified value (silent NULL).

const (
	NotNull Nullability = iota
	Null
	SilentNull
)

The values for NullType.

type NumVal

type NumVal struct {
	constant.Value

	// We preserve the "original" string representation (before folding).
	OrigString string
	// contains filtered or unexported fields
}

NumVal represents a constant numeric value.

func (*NumVal) AvailableTypes

func (expr *NumVal) AvailableTypes() []Datum

AvailableTypes implements the Constant interface.

func (*NumVal) Format

func (expr *NumVal) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*NumVal) ResolveAsType

func (expr *NumVal) ResolveAsType(ctx *SemaContext, typ Datum) (Datum, error)

ResolveAsType implements the Constant interface.

func (*NumVal) String

func (node *NumVal) String() string

func (*NumVal) TypeCheck

func (expr *NumVal) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*NumVal) Walk

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

Walk implements the Expr interface.

type OnConflict

type OnConflict struct {
	Columns   NameList
	Exprs     UpdateExprs
	Where     *Where
	DoNothing bool
}

OnConflict represents an `ON CONFLICT (columns) DO UPDATE SET exprs WHERE where` clause.

The zero value for OnConflict is used to signal the UPSERT short form, which uses the primary key for as the conflict index and the values being inserted for Exprs.

func (*OnConflict) IsUpsertAlias

func (oc *OnConflict) IsUpsertAlias() bool

IsUpsertAlias returns true if the UPSERT syntactic sugar was used.

type OnJoinCond

type OnJoinCond struct {
	Expr Expr
}

OnJoinCond represents an ON join condition.

func (*OnJoinCond) Format

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

Format implements the NodeFormatter interface.

type OrExpr

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

OrExpr represents an OR expression.

func NewTypedOrExpr

func NewTypedOrExpr(left, right TypedExpr) *OrExpr

NewTypedOrExpr returns a new OrExpr that is verified to be well-typed.

func (*OrExpr) Eval

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

Eval implements the TypedExpr interface.

func (*OrExpr) Format

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

Format implements the NodeFormatter interface.

func (OrExpr) ReturnType

func (ta OrExpr) ReturnType() Datum

func (*OrExpr) String

func (node *OrExpr) String() string

func (*OrExpr) TypeCheck

func (expr *OrExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*OrExpr) TypedLeft

func (node *OrExpr) TypedLeft() TypedExpr

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

func (*OrExpr) TypedRight

func (node *OrExpr) TypedRight() TypedExpr

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

func (*OrExpr) Walk

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

Walk implements the Expr interface.

type Order

type Order struct {
	Expr      Expr
	Direction Direction
}

Order represents an ordering expression.

func (*Order) Format

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

Format implements the NodeFormatter interface.

type OrderBy

type OrderBy []*Order

OrderBy represents an ORDER By clause.

func (OrderBy) Format

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

Format implements the NodeFormatter interface.

type OverlayExpr

type OverlayExpr struct {
	FuncExpr
}

OverlayExpr represents an overlay function call.

func (*OverlayExpr) Eval

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

Eval implements the TypedExpr interface.

func (*OverlayExpr) Format

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

Format implements the NodeFormatter interface.

func (OverlayExpr) ReturnType

func (ta OverlayExpr) ReturnType() Datum

func (*OverlayExpr) String

func (node *OverlayExpr) String() string

type ParenExpr

type ParenExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

ParenExpr represents a parenthesized expression.

func (*ParenExpr) Eval

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

Eval implements the TypedExpr interface.

func (*ParenExpr) Format

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

Format implements the NodeFormatter interface.

func (ParenExpr) ReturnType

func (ta ParenExpr) ReturnType() Datum

func (*ParenExpr) String

func (node *ParenExpr) String() string

func (*ParenExpr) TypeCheck

func (expr *ParenExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ParenExpr) TypedInnerExpr

func (node *ParenExpr) TypedInnerExpr() TypedExpr

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

func (*ParenExpr) Walk

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

Walk implements the Expr interface.

type ParenSelect

type ParenSelect struct {
	Select *Select
}

ParenSelect represents a parenthesized SELECT/UNION/VALUES statement.

func (*ParenSelect) Format

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

Format implements the NodeFormatter interface.

func (*ParenSelect) StatementTag

func (*ParenSelect) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ParenSelect) StatementType

func (*ParenSelect) StatementType() StatementType

StatementType implements the Statement interface.

func (*ParenSelect) String

func (n *ParenSelect) String() string

func (*ParenSelect) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type ParenTableExpr

type ParenTableExpr struct {
	Expr TableExpr
}

ParenTableExpr represents a parenthesized TableExpr.

func (*ParenTableExpr) Format

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

Format implements the NodeFormatter interface.

func (*ParenTableExpr) String

func (node *ParenTableExpr) String() string

type Parser

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

Parser wraps a scanner, parser and other utilities present in the parser package.

func (*Parser) AggregateInExpr

func (p *Parser) AggregateInExpr(expr Expr) bool

AggregateInExpr determines if an Expr contains an aggregate function.

func (*Parser) IsAggregate

func (p *Parser) IsAggregate(n *SelectClause) bool

IsAggregate determines if SelectClause contains an aggregate function.

func (*Parser) NormalizeExpr

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

NormalizeExpr is wrapper around ctx.NormalizeExpr which avoids allocation of a normalizeVisitor.

func (*Parser) Parse

func (p *Parser) Parse(sql string, syntax Syntax) (stmts StatementList, err error)

Parse parses the sql and returns a list of statements.

type Placeholder

type Placeholder struct {
	Name string
}

Placeholder represents a named placeholder.

func (Placeholder) Format

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

Format implements the NodeFormatter interface.

func (Placeholder) String

func (node Placeholder) String() string

func (Placeholder) TypeCheck

func (expr Placeholder) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (Placeholder) Variable

func (Placeholder) Variable()

Variable implements the VariableExpr interface.

func (Placeholder) Walk

func (expr Placeholder) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type PlaceholderInfo

type PlaceholderInfo struct {
	Values QueryArguments
	Types  PlaceholderTypes
}

PlaceholderInfo defines the interface to SQL placeholders.

func NewPlaceholderInfo

func NewPlaceholderInfo() *PlaceholderInfo

NewPlaceholderInfo constructs an empty PlaceholderInfo.

func (*PlaceholderInfo) Assign

func (p *PlaceholderInfo) Assign(src *PlaceholderInfo)

Assign resets the PlaceholderInfo to the contents of src. If src is nil, the map is cleared.

func (*PlaceholderInfo) Clear

func (p *PlaceholderInfo) Clear()

Clear resets the placeholder info map.

func (*PlaceholderInfo) IsUnresolvedPlaceholder

func (p *PlaceholderInfo) IsUnresolvedPlaceholder(expr Expr) bool

IsUnresolvedPlaceholder returns whether expr is an unresolved placeholder. In other words, it returns whether the provided expression is a placeholder expression or a placeholder expression within nested parentheses, and if so, whether the placeholder's type remains unset in the PlaceholderInfo.

func (*PlaceholderInfo) SetType

func (p *PlaceholderInfo) SetType(name string, typ Datum) error

SetType assignes a known type to a placeholder. Reports an error if another type was previously assigned.

func (*PlaceholderInfo) SetTypes

func (p *PlaceholderInfo) SetTypes(src PlaceholderTypes)

SetTypes resets the type and values in the map and replaces the types map by an alias to src. If src is nil, the map is cleared. The types map is aliased because the invoking code from pgwire/v3.go for sql.Prepare needs to receive the updated type assignments after Prepare completes.

func (*PlaceholderInfo) SetValue

func (p *PlaceholderInfo) SetValue(name string, val Datum)

SetValue assigns a known value to a placeholder. If no type is known yet, it is inferred from the assigned value.

func (*PlaceholderInfo) Type

func (p *PlaceholderInfo) Type(name string) (Datum, bool)

Type returns the known type of a placeholder. Returns false in the 2nd value if the placeholder is not typed.

func (*PlaceholderInfo) Value

func (p *PlaceholderInfo) Value(name string) (Datum, bool)

Value returns the known value of a placeholder. Returns false in the 2nd value if the placeholder does not have a value.

type PlaceholderTypes

type PlaceholderTypes map[string]Datum

PlaceholderTypes relates placeholder names to their resolved type.

func (PlaceholderTypes) ProcessPlaceholderAnnotations

func (p PlaceholderTypes) ProcessPlaceholderAnnotations(stmt Statement) error

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

  • the placeholder is the subject of an explicit type annotation in at least one of its occurrences. If it is subject to multiple explicit type annotations where the types are not all in agreement, or if the placeholder already has an inferred type in the placeholder map which conflicts with the explicit type annotation type, an error will be thrown.
  • the placeholder is the subject to an implicit type annotation, meaning that it is not subject to an explicit type annotation, and that in all occurrences of the placeholder, it is subject to a cast to the same type. If it is subject to casts of multiple types, no error will be thrown, but the placeholder type will not be inferred. If a type has already been assigned for the placeholder in the placeholder map, no error will be thrown, and the placeholder will keep it's previously inferred type.

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

type Prepare

type Prepare struct {
	Name      Name
	Types     []ColumnType
	Statement Statement
}

Prepare represents a PREPARE statement.

func (*Prepare) Format

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

Format implements the NodeFormatter interface.

func (*Prepare) StatementTag

func (*Prepare) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Prepare) StatementType

func (*Prepare) StatementType() StatementType

StatementType implements the Statement interface.

func (*Prepare) String

func (n *Prepare) String() string

type PrimaryKeyConstraint

type PrimaryKeyConstraint struct{}

PrimaryKeyConstraint represents NULL on a column.

type QualifiedName

type QualifiedName struct {
	Base     Name
	Indirect Indirection
	// contains filtered or unexported fields
}

QualifiedName is a base name and an optional indirection expression.

func StarExpr

func StarExpr() *QualifiedName

StarExpr is a convenience function that represents an unqualified "*".

func (*QualifiedName) ClearString

func (node *QualifiedName) ClearString()

ClearString causes String to return the current (possibly normalized) name instead of the original name (used for testing).

func (*QualifiedName) Column

func (node *QualifiedName) Column() string

Column returns the column portion of the name. Note that the returned string is not quoted even if the name is a keyword.

func (*QualifiedName) Database

func (node *QualifiedName) Database() string

Database returns the database portion of the name. Note that the returned string is not quoted even if the name is a keyword.

func (*QualifiedName) Eval

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

Eval implements the TypedExpr interface.

func (*QualifiedName) Format

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

Format implements the NodeFormatter interface.

func (*QualifiedName) IsStar

func (node *QualifiedName) IsStar() bool

IsStar returns true iff the qualified name contains matches "".* or table.*.

func (*QualifiedName) NormalizeColumnName

func (node *QualifiedName) NormalizeColumnName() error

NormalizeColumnName normalizes the qualified name to contain a table name as prefix, returning an error if unable to do so or if the name is not a valid column name (e.g. it contains too many indirections). If normalization occurred, the modified qualified name will have n.Base == "" to indicate no explicit table was specified. The incoming qualified name should have one of the following forms:

*
table.*
column
column[array-indirection]
table.column
table.column[array-indirection]

Note that "table" may be the empty string. On successful normalization the qualified name will have one of the forms:

table.*
table.column
table.column[array-indirection]

func (*QualifiedName) NormalizeTableName

func (node *QualifiedName) NormalizeTableName(database string) error

NormalizeTableName normalizes the qualified name to contain a database name as prefix, returning an error if unable to do so or if the name is not a valid table name (e.g. it contains an array indirection). The incoming qualified name should have one of the following forms:

table
database.table
table@index
database.table@index

On successful normalization, the qualified name will have the form:

database.table@index

func (*QualifiedName) QualifyWithDatabase

func (node *QualifiedName) QualifyWithDatabase(database string) error

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

func (*QualifiedName) ReturnType

func (node *QualifiedName) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*QualifiedName) String

func (node *QualifiedName) String() string

func (*QualifiedName) Table

func (node *QualifiedName) Table() string

Table returns the table portion of the name. Note that the returned string is not quoted even if the name is a keyword.

func (*QualifiedName) TypeCheck

func (expr *QualifiedName) TypeCheck(_ *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*QualifiedName) Variable

func (*QualifiedName) Variable()

Variable implements the VariableExpr interface.

func (*QualifiedName) Walk

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

Walk implements the Expr interface.

type QualifiedNames

type QualifiedNames []*QualifiedName

QualifiedNames represents a command separated list (see the String method) of qualified names.

func (QualifiedNames) Format

func (n QualifiedNames) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type QueryArguments

type QueryArguments map[string]Datum

QueryArguments relates placeholder names to their provided query argument.

type RangeCond

type RangeCond struct {
	Not      bool
	Left     Expr
	From, To Expr
	// contains filtered or unexported fields
}

RangeCond represents a BETWEEN or a NOT BETWEEN expression.

func (*RangeCond) Eval

func (expr *RangeCond) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*RangeCond) Format

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

Format implements the NodeFormatter interface.

func (RangeCond) ReturnType

func (ta RangeCond) ReturnType() Datum

func (*RangeCond) String

func (node *RangeCond) String() string

func (*RangeCond) TypeCheck

func (expr *RangeCond) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*RangeCond) TypedFrom

func (node *RangeCond) TypedFrom() TypedExpr

TypedFrom returns the RangeCond's from expression as a TypedExpr.

func (*RangeCond) TypedLeft

func (node *RangeCond) TypedLeft() TypedExpr

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

func (*RangeCond) TypedTo

func (node *RangeCond) TypedTo() TypedExpr

TypedTo returns the RangeCond's to expression as a TypedExpr.

func (*RangeCond) Walk

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

Walk implements the Expr interface.

type RegexpCache

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

A RegexpCache is a cache used to store compiled regular expressions. The cache is safe for concurrent use by multiple goroutines. It is also safe to use the cache through a nil reference, where it will act like a valid cache with no capacity.

func NewRegexpCache

func NewRegexpCache(size int) *RegexpCache

NewRegexpCache creates a new RegexpCache of the given size. The underlying cache internally uses a hash map, so lookups are cheap.

func (*RegexpCache) GetRegexp

func (rc *RegexpCache) GetRegexp(key regexpCacheKey) (*regexp.Regexp, error)

GetRegexp consults the cache for the regular expressions stored for the given key, compiling the key's pattern if it is not already in the cache.

func (*RegexpCache) Len

func (rc *RegexpCache) Len() int

Len returns the number of compiled regular expressions in the cache.

type ReleaseSavepoint

type ReleaseSavepoint struct {
	Savepoint string
}

ReleaseSavepoint represents a RELEASE SAVEPOINT <name> statement.

func (*ReleaseSavepoint) Format

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

Format implements the NodeFormatter interface.

func (*ReleaseSavepoint) StatementTag

func (*ReleaseSavepoint) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ReleaseSavepoint) StatementType

func (*ReleaseSavepoint) StatementType() StatementType

StatementType implements the Statement interface.

func (*ReleaseSavepoint) String

func (n *ReleaseSavepoint) String() string

type RenameColumn

type RenameColumn struct {
	Table   *QualifiedName
	Name    Name
	NewName Name
	// IfExists refers to the table, not the column.
	IfExists bool
}

RenameColumn represents a RENAME COLUMN statement.

func (*RenameColumn) Format

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

Format implements the NodeFormatter interface.

func (*RenameColumn) StatementTag

func (*RenameColumn) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameColumn) StatementType

func (*RenameColumn) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameColumn) String

func (n *RenameColumn) String() string

type RenameDatabase

type RenameDatabase struct {
	Name    Name
	NewName Name
}

RenameDatabase represents a RENAME DATABASE statement.

func (*RenameDatabase) Format

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

Format implements the NodeFormatter interface.

func (*RenameDatabase) StatementTag

func (*RenameDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameDatabase) StatementType

func (*RenameDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameDatabase) String

func (n *RenameDatabase) String() string

type RenameIndex

type RenameIndex struct {
	Index    *TableNameWithIndex
	NewName  Name
	IfExists bool
}

RenameIndex represents a RENAME INDEX statement.

func (*RenameIndex) Format

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

Format implements the NodeFormatter interface.

func (*RenameIndex) StatementTag

func (*RenameIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameIndex) StatementType

func (*RenameIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameIndex) String

func (n *RenameIndex) String() string

type RenameTable

type RenameTable struct {
	Name     *QualifiedName
	NewName  *QualifiedName
	IfExists bool
}

RenameTable represents a RENAME TABLE statement.

func (*RenameTable) Format

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

Format implements the NodeFormatter interface.

func (*RenameTable) StatementTag

func (*RenameTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameTable) StatementType

func (*RenameTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameTable) String

func (n *RenameTable) String() string

type ReturningExprs

type ReturningExprs SelectExprs

ReturningExprs represents RETURNING expressions.

func (ReturningExprs) Format

func (r ReturningExprs) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (ReturningExprs) StatementType

func (r ReturningExprs) StatementType() StatementType

StatementType implements the Statement interface.

type Revoke

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

Revoke represents a REVOKE statements. PrivilegeList and TargetList are defined in grant.go

func (*Revoke) Format

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

Format implements the NodeFormatter interface.

func (*Revoke) StatementTag

func (*Revoke) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Revoke) StatementType

func (*Revoke) StatementType() StatementType

StatementType implements the Statement interface.

func (*Revoke) String

func (n *Revoke) String() string

type RollbackToSavepoint

type RollbackToSavepoint struct {
	Savepoint string
}

RollbackToSavepoint represents a ROLLBACK TO SAVEPOINT <name> statement.

func (*RollbackToSavepoint) Format

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

Format implements the NodeFormatter interface.

func (*RollbackToSavepoint) StatementTag

func (*RollbackToSavepoint) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RollbackToSavepoint) StatementType

func (*RollbackToSavepoint) StatementType() StatementType

StatementType implements the Statement interface.

func (*RollbackToSavepoint) String

func (n *RollbackToSavepoint) String() string

type RollbackTransaction

type RollbackTransaction struct{}

RollbackTransaction represents a ROLLBACK statement.

func (*RollbackTransaction) Format

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

Format implements the NodeFormatter interface.

func (*RollbackTransaction) StatementTag

func (*RollbackTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RollbackTransaction) StatementType

func (*RollbackTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*RollbackTransaction) String

func (n *RollbackTransaction) String() string

type Savepoint

type Savepoint struct {
	Name string
}

Savepoint represents a SAVEPOINT <name> statement.

func (*Savepoint) Format

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

Format implements the NodeFormatter interface.

func (*Savepoint) StatementTag

func (*Savepoint) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Savepoint) StatementType

func (*Savepoint) StatementType() StatementType

StatementType implements the Statement interface.

func (*Savepoint) String

func (n *Savepoint) String() string

type Scanner

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

Scanner lexes SQL statements.

func MakeScanner

func MakeScanner(str string, syntax Syntax) Scanner

MakeScanner makes a Scanner from str.

func (*Scanner) Error

func (s *Scanner) Error(e string)

func (*Scanner) Lex

func (s *Scanner) Lex(lval *sqlSymType) int

Lex lexes a token from input.

func (*Scanner) Tokens

func (s *Scanner) Tokens(f func(token int))

Tokens calls f on all tokens of the input until an EOF is encountered.

type Select

type Select struct {
	Select  SelectStatement
	OrderBy OrderBy
	Limit   *Limit
}

Select represents a SelectStatement with an ORDER and/or LIMIT.

func (*Select) CopyNode

func (stmt *Select) CopyNode() *Select

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

func (*Select) Format

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

Format implements the NodeFormatter interface.

func (*Select) StatementTag

func (*Select) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Select) StatementType

func (*Select) StatementType() StatementType

StatementType implements the Statement interface.

func (*Select) String

func (n *Select) String() string

func (*Select) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type SelectClause

type SelectClause struct {
	Distinct bool
	Exprs    SelectExprs
	From     TableExprs
	Where    *Where
	GroupBy  GroupBy
	Having   *Where
	Lock     string
	// contains filtered or unexported fields
}

SelectClause represents a SELECT statement.

func (*SelectClause) CopyNode

func (stmt *SelectClause) CopyNode() *SelectClause

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

func (*SelectClause) Format

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

Format implements the NodeFormatter interface.

func (*SelectClause) StatementTag

func (*SelectClause) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SelectClause) StatementType

func (*SelectClause) StatementType() StatementType

StatementType implements the Statement interface.

func (*SelectClause) String

func (n *SelectClause) String() string

func (*SelectClause) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type SelectExpr

type SelectExpr struct {
	Expr Expr
	As   Name
}

SelectExpr represents a SELECT expression.

func (SelectExpr) Format

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

Format implements the NodeFormatter interface.

type SelectExprs

type SelectExprs []SelectExpr

SelectExprs represents SELECT expressions.

func (SelectExprs) Format

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

Format implements the NodeFormatter interface.

type SelectStatement

type SelectStatement interface {
	Statement
	// contains filtered or unexported methods
}

SelectStatement any SELECT statement.

type SemaContext

type SemaContext struct {
	// Placeholders relates placeholder names to their type and, later, value.
	Placeholders *PlaceholderInfo

	// Location references the *Location on the current Session.
	Location **time.Location
}

SemaContext defines the context in which to perform semantic analysis on an expression syntax tree.

func MakeSemaContext

func MakeSemaContext() SemaContext

MakeSemaContext initializes a simple SemaContext suitable for "lightweight" type checking such as the one performed for default expressions.

type Set

type Set struct {
	Name   *QualifiedName
	Values Exprs
}

Set represents a SET statement.

func (*Set) CopyNode

func (stmt *Set) CopyNode() *Set

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

func (*Set) Format

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

Format implements the NodeFormatter interface.

func (*Set) StatementTag

func (*Set) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Set) StatementType

func (*Set) StatementType() StatementType

StatementType implements the Statement interface.

func (*Set) String

func (n *Set) String() string

func (*Set) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type SetDefaultIsolation

type SetDefaultIsolation struct {
	Isolation IsolationLevel
}

SetDefaultIsolation represents a SET SESSION CHARACTERISTICS AS TRANSACTION statement.

func (*SetDefaultIsolation) Format

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

Format implements the NodeFormatter interface.

func (*SetDefaultIsolation) StatementTag

func (*SetDefaultIsolation) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetDefaultIsolation) StatementType

func (*SetDefaultIsolation) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetDefaultIsolation) String

func (n *SetDefaultIsolation) String() string

type SetTimeZone

type SetTimeZone struct {
	Value Expr
}

SetTimeZone represents a SET TIME ZONE statement.

func (*SetTimeZone) Format

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

Format implements the NodeFormatter interface.

func (*SetTimeZone) StatementTag

func (*SetTimeZone) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetTimeZone) StatementType

func (*SetTimeZone) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetTimeZone) String

func (n *SetTimeZone) String() string

type SetTransaction

type SetTransaction struct {
	Isolation    IsolationLevel
	UserPriority UserPriority
}

SetTransaction represents a SET TRANSACTION statement.

func (*SetTransaction) Format

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

Format implements the NodeFormatter interface.

func (*SetTransaction) StatementTag

func (*SetTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetTransaction) StatementType

func (*SetTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetTransaction) String

func (n *SetTransaction) String() string

type Show

type Show struct {
	Name string
}

Show represents a SHOW statement.

func (*Show) Format

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

Format implements the NodeFormatter interface.

func (*Show) StatementTag

func (*Show) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Show) StatementType

func (*Show) StatementType() StatementType

StatementType implements the Statement interface.

func (*Show) String

func (n *Show) String() string

type ShowColumns

type ShowColumns struct {
	Table *QualifiedName
}

ShowColumns represents a SHOW COLUMNS statement.

func (*ShowColumns) Format

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

Format implements the NodeFormatter interface.

func (*ShowColumns) StatementTag

func (*ShowColumns) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowColumns) StatementType

func (*ShowColumns) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowColumns) String

func (n *ShowColumns) String() string

type ShowConstraints

type ShowConstraints struct {
	Table *QualifiedName
}

ShowConstraints represents a SHOW CONSTRAINTS statement.

func (*ShowConstraints) Format

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

Format implements the NodeFormatter interface.

func (*ShowConstraints) StatementTag

func (*ShowConstraints) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowConstraints) StatementType

func (*ShowConstraints) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowConstraints) String

func (n *ShowConstraints) String() string

type ShowCreateTable

type ShowCreateTable struct {
	Table *QualifiedName
}

ShowCreateTable represents a SHOW CREATE TABLE statement.

func (*ShowCreateTable) Format

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

Format implements the NodeFormatter interface.

func (*ShowCreateTable) StatementTag

func (*ShowCreateTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowCreateTable) StatementType

func (*ShowCreateTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowCreateTable) String

func (n *ShowCreateTable) String() string

type ShowDatabases

type ShowDatabases struct {
}

ShowDatabases represents a SHOW DATABASES statement.

func (*ShowDatabases) Format

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

Format implements the NodeFormatter interface.

func (*ShowDatabases) StatementTag

func (*ShowDatabases) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowDatabases) StatementType

func (*ShowDatabases) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowDatabases) String

func (n *ShowDatabases) String() string

type ShowGrants

type ShowGrants struct {
	Targets  *TargetList
	Grantees NameList
}

ShowGrants represents a SHOW GRANTS statement. TargetList is defined in grant.go.

func (*ShowGrants) Format

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

Format implements the NodeFormatter interface.

func (*ShowGrants) StatementTag

func (*ShowGrants) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowGrants) StatementType

func (*ShowGrants) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowGrants) String

func (n *ShowGrants) String() string

type ShowIndex

type ShowIndex struct {
	Table *QualifiedName
}

ShowIndex represents a SHOW INDEX statement.

func (*ShowIndex) Format

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

Format implements the NodeFormatter interface.

func (*ShowIndex) StatementTag

func (*ShowIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowIndex) StatementType

func (*ShowIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowIndex) String

func (n *ShowIndex) String() string

type ShowTables

type ShowTables struct {
	Name *QualifiedName
}

ShowTables represents a SHOW TABLES statement.

func (*ShowTables) Format

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

Format implements the NodeFormatter interface.

func (*ShowTables) StatementTag

func (*ShowTables) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowTables) StatementType

func (*ShowTables) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowTables) String

func (n *ShowTables) String() string

type SimpleVisitFn

type SimpleVisitFn func(expr Expr) (err error, recurse bool, newExpr Expr)

SimpleVisitFn is a function that is run for every node in the VisitPre stage; see SimpleVisit.

type SingleType

type SingleType struct {
	Typ Datum
}

SingleType is a typeList implementation which accepts a single argument of type typ. It is logically identical to an ArgTypes implementation with length 1, but avoids the slice allocation.

type StarIndirection

type StarIndirection string

StarIndirection represents ".*" in an indirection expression.

func (StarIndirection) Format

func (s StarIndirection) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type Statement

type Statement interface {
	fmt.Stringer
	NodeFormatter
	StatementType() StatementType
	// StatementTag is a short string identifying the type of statement
	// (usually a single verb). This is different than the Stringer output,
	// which is the actual statement (including args).
	// TODO(dt): Currently tags are always pg-compatible in the future it
	// might make sense to pass a tag format specifier.
	StatementTag() string
}

Statement represents a statement.

func ParseOne

func ParseOne(sql string, syntax Syntax) (Statement, error)

ParseOne parses a sql statement.

func ParseOneTraditional

func ParseOneTraditional(sql string) (Statement, error)

ParseOneTraditional is short-hand for ParseOne(sql, Traditional)

func WalkStmt

func WalkStmt(v Visitor, stmt Statement) (newStmt Statement, changed bool)

WalkStmt walks the entire parsed stmt calling WalkExpr on each expression, and replacing each expression with the one returned by WalkExpr.

type StatementList

type StatementList []Statement

StatementList is a list of statements.

func (StatementList) Format

func (l StatementList) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (StatementList) String

func (l StatementList) String() string

type StatementType

type StatementType int

StatementType is the enumerated type for Statement return styles on the wire.

const (
	// Ack indicates that the statement does not have a meaningful
	// return. Examples include SET, BEGIN, COMMIT.
	Ack StatementType = iota
	// DDL indicates that the statement mutates the database schema.
	DDL
	// RowsAffected indicates that the statement returns the count of
	// affected rows.
	RowsAffected
	// Rows indicates that the statement returns the affected rows after
	// the statement was applied.
	Rows
	// Unknown indicates that the statement does not have a known
	// return style at the time of parsing. This is not first in the
	// enumeration because it is more convenient to have Ack as a zero
	// value, and because the use of Unknown should be an explicit choice.
	// The primary example of this statement type is EXECUTE, where the
	// statement type depends on the statement type of the prepared statement
	// being executed.
	Unknown
)

type StrVal

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

StrVal represents a constant string value.

func (*StrVal) AvailableTypes

func (expr *StrVal) AvailableTypes() []Datum

AvailableTypes implements the Constant interface.

func (*StrVal) Format

func (expr *StrVal) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

func (*StrVal) ResolveAsType

func (expr *StrVal) ResolveAsType(ctx *SemaContext, typ Datum) (Datum, error)

ResolveAsType implements the Constant interface.

func (*StrVal) String

func (node *StrVal) String() string

func (*StrVal) TypeCheck

func (expr *StrVal) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*StrVal) Walk

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

Walk implements the Expr interface.

type StringColType

type StringColType struct {
	Name string
	N    int
}

StringColType represents a STRING, CHAR or VARCHAR type.

func (*StringColType) Format

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

Format implements the NodeFormatter interface.

func (*StringColType) String

func (node *StringColType) String() string

type Subquery

type Subquery struct {
	Select SelectStatement
}

Subquery represents a subquery.

func (*Subquery) Eval

func (expr *Subquery) Eval(_ *EvalContext) (Datum, error)

Eval implements the TypedExpr interface.

func (*Subquery) Format

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

Format implements the NodeFormatter interface.

func (*Subquery) ReturnType

func (node *Subquery) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*Subquery) String

func (node *Subquery) String() string

func (*Subquery) TypeCheck

func (expr *Subquery) TypeCheck(_ *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Subquery) Variable

func (*Subquery) Variable()

Variable implements the VariableExpr interface.

func (*Subquery) Walk

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

Walk implements the Expr interface.

type Syntax

type Syntax int

Syntax is an enum of the various syntax types.

const (
	// Implicit default, must stay in the zero-value position.
	Traditional Syntax = iota
	Modern
)

func (Syntax) String

func (i Syntax) String() string

type TableDef

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

TableDef represents a column, index or constraint definition within a CREATE TABLE statement.

type TableDefs

type TableDefs []TableDef

TableDefs represents a list of table definitions.

func (TableDefs) Format

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

Format implements the NodeFormatter interface.

type TableExpr

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

TableExpr represents a table expression.

type TableExprs

type TableExprs []TableExpr

TableExprs represents a list of table expressions.

func (TableExprs) Format

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

Format implements the NodeFormatter interface.

type TableNameWithIndex

type TableNameWithIndex struct {
	Table *QualifiedName
	Index Name
}

TableNameWithIndex represents a "table@index", used in statements that specifically refer to an index.

func (*TableNameWithIndex) Format

func (n *TableNameWithIndex) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type TableNameWithIndexList

type TableNameWithIndexList []*TableNameWithIndex

TableNameWithIndexList is a list of indexes.

func (TableNameWithIndexList) Format

func (n TableNameWithIndexList) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type TargetList

type TargetList struct {
	Databases NameList
	Tables    QualifiedNames
}

TargetList represents a list of targets. Only one field may be non-nil.

func (TargetList) Format

func (tl TargetList) Format(buf *bytes.Buffer, f FmtFlags)

Format implements the NodeFormatter interface.

type TargetType

type TargetType int

TargetType represents the type of target.

const (
	TargetDatabase TargetType = iota
)

Enums for target and privilege types.

func (TargetType) String

func (tt TargetType) String() string

type TimestampColType

type TimestampColType struct {
}

TimestampColType represents a TIMESTAMP type.

func (*TimestampColType) Format

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

Format implements the NodeFormatter interface.

func (*TimestampColType) String

func (node *TimestampColType) String() string

type TimestampTZColType

type TimestampTZColType struct {
}

TimestampTZColType represents a TIMESTAMP type.

func (*TimestampTZColType) Format

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

Format implements the NodeFormatter interface.

func (*TimestampTZColType) String

func (node *TimestampTZColType) String() string

type Truncate

type Truncate struct {
	Tables       QualifiedNames
	DropBehavior DropBehavior
}

Truncate represents a TRUNCATE statement.

func (*Truncate) Format

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

Format implements the NodeFormatter interface.

func (*Truncate) StatementTag

func (*Truncate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Truncate) StatementType

func (*Truncate) StatementType() StatementType

StatementType implements the Statement interface.

func (*Truncate) String

func (n *Truncate) String() string

type Tuple

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

Tuple represents a parenthesized list of expressions.

func (*Tuple) Eval

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

Eval implements the TypedExpr interface.

func (*Tuple) Format

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

Format implements the NodeFormatter interface.

func (*Tuple) ReturnType

func (node *Tuple) ReturnType() Datum

ReturnType implements the TypedExpr interface.

func (*Tuple) String

func (node *Tuple) String() string

func (*Tuple) TypeCheck

func (expr *Tuple) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Tuple) Walk

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

Walk implements the Expr interface.

type TypedExpr

type TypedExpr interface {
	Expr
	// Eval evaluates an SQL expression. Expression evaluation is a mostly
	// straightforward walk over the parse tree. The only significant complexity is
	// the handling of types and implicit conversions. See binOps and cmpOps for
	// more details. Note that expression evaluation returns an error if certain
	// node types are encountered: Placeholder, QualifiedName or Subquery. These nodes
	// should be replaced prior to expression evaluation by an appropriate
	// WalkExpr. For example, Placeholder should be replace by the argument passed from
	// the client.
	Eval(*EvalContext) (Datum, error)
	// ReturnType provides the type of the TypedExpr, which is the type of Datum that
	// the TypedExpr will return when evaluated.
	ReturnType() Datum
}

TypedExpr represents a well-typed expression.

func ReType

func ReType(expr TypedExpr, wantedType Datum) (TypedExpr, error)

ReType ensures that the given numeric expression evaluates to the requested type, inserting a cast if necessary.

func TypeCheck

func TypeCheck(expr Expr, ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck performs type checking on the provided expression tree, returning the new typed expression tree, which additionally permits evaluation and type introspection globally and on each sub-tree.

While doing so, it will fold numeric constants and bind placeholder names to their inferred types in the provided context. The optional desired parameter can be used to hint the desired type for the root of the resulting typed expression tree.

func TypeCheckAndRequire

func TypeCheckAndRequire(expr Expr, ctx *SemaContext, required Datum, op string) (TypedExpr, error)

TypeCheckAndRequire performs type checking on the provided expression tree in an identical manner to TypeCheck. It then asserts that the resulting TypedExpr has the provided return type, returning both the typed expression and an error if it does not.

func TypeConstants

func TypeConstants(expr Expr) (TypedExpr, error)

TypeConstants type checks all Constant literal expressions, resolving them as the Datum representations of their values. Before doing so, it first folds all numeric constants.

This means that Constants will become TypedExprs so that they can be used in contexts which expect a TypedExpr tree (such as Normalization). As such, the function is primarily intended for use while testing expressions where full type checking is not desired.

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

type TypedExprs

type TypedExprs []TypedExpr

TypedExprs represents a list of well-typed value expressions. It's not a valid expression because it's not parenthesized.

func (TypedExprs) String

func (node TypedExprs) String() string

type UnaryExpr

type UnaryExpr struct {
	Operator UnaryOperator
	Expr     Expr
	// contains filtered or unexported fields
}

UnaryExpr represents a unary value expression.

func (*UnaryExpr) Eval

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

Eval implements the TypedExpr interface.

func (*UnaryExpr) Format

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

Format implements the NodeFormatter interface.

func (UnaryExpr) ReturnType

func (ta UnaryExpr) ReturnType() Datum

func (*UnaryExpr) String

func (node *UnaryExpr) String() string

func (*UnaryExpr) TypeCheck

func (expr *UnaryExpr) TypeCheck(ctx *SemaContext, desired Datum) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*UnaryExpr) TypedInnerExpr

func (node *UnaryExpr) TypedInnerExpr() TypedExpr

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

func (*UnaryExpr) Walk

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

Walk implements the Expr interface.

type UnaryOp

type UnaryOp struct {
	Typ        Datum
	ReturnType Datum
	// contains filtered or unexported fields
}

UnaryOp is a unary operator.

type UnaryOperator

type UnaryOperator int

UnaryOperator represents a unary operator.

const (
	UnaryPlus UnaryOperator = iota
	UnaryMinus
	UnaryComplement
)

UnaryExpr.Operator

func (UnaryOperator) String

func (i UnaryOperator) String() string

type UnionClause

type UnionClause struct {
	Type        UnionType
	Left, Right *Select
	All         bool
}

UnionClause represents a UNION statement.

func (*UnionClause) Format

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

Format implements the NodeFormatter interface.

func (*UnionClause) StatementTag

func (*UnionClause) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*UnionClause) StatementType

func (*UnionClause) StatementType() StatementType

StatementType implements the Statement interface.

func (*UnionClause) String

func (n *UnionClause) String() string

type UnionType

type UnionType int

UnionType represents one of the three set operations in sql.

const (
	UnionOp UnionType = iota
	IntersectOp
	ExceptOp
)

Union.Type

func (UnionType) String

func (i UnionType) String() string

type UniqueConstraint

type UniqueConstraint struct{}

UniqueConstraint represents UNIQUE on a column.

type UniqueConstraintTableDef

type UniqueConstraintTableDef struct {
	IndexTableDef
	PrimaryKey bool
}

UniqueConstraintTableDef represents a unique constraint within a CREATE TABLE statement.

func (*UniqueConstraintTableDef) Format

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

Format implements the NodeFormatter interface.

type Update

type Update struct {
	Table     TableExpr
	Exprs     UpdateExprs
	Where     *Where
	Returning ReturningExprs
}

Update represents an UPDATE statement.

func (*Update) CopyNode

func (stmt *Update) CopyNode() *Update

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

func (*Update) Format

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

Format implements the NodeFormatter interface.

func (*Update) StatementTag

func (*Update) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Update) StatementType

func (n *Update) StatementType() StatementType

StatementType implements the Statement interface.

func (*Update) String

func (n *Update) String() string

func (*Update) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type UpdateExpr

type UpdateExpr struct {
	Tuple bool
	Names QualifiedNames
	Expr  Expr
}

UpdateExpr represents an update expression.

func (*UpdateExpr) Format

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

Format implements the NodeFormatter interface.

type UpdateExprs

type UpdateExprs []*UpdateExpr

UpdateExprs represents a list of update expressions.

func (UpdateExprs) Format

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

Format implements the NodeFormatter interface.

type UserPriority

type UserPriority int

UserPriority holds the user priority for a transaction.

const (
	UnspecifiedUserPriority UserPriority = iota
	Low
	Normal
	High
)

UserPriority values

func (UserPriority) String

func (up UserPriority) String() string

type UsingJoinCond

type UsingJoinCond struct {
	Cols NameList
}

UsingJoinCond represents a USING join condition.

func (*UsingJoinCond) Format

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

Format implements the NodeFormatter interface.

type ValuesClause

type ValuesClause struct {
	Tuples []*Tuple
}

ValuesClause represents a VALUES clause.

func (*ValuesClause) Format

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

Format implements the NodeFormatter interface.

func (ValuesClause) StatementTag

func (ValuesClause) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (ValuesClause) StatementType

func (ValuesClause) StatementType() StatementType

StatementType implements the Statement interface.

func (*ValuesClause) String

func (n *ValuesClause) String() string

func (*ValuesClause) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type VariableExpr

type VariableExpr interface {
	Expr
	Variable()
}

VariableExpr is an Expr that may change per row. It is used to signal the evaluation/simplification machinery that the underlying Expr is not constant.

type VariadicType

type VariadicType struct {
	Typ Datum
}

VariadicType is a typeList implementation which accepts any number of arguments and matches when each argument is either NULL or of the type typ.

type Visitor

type Visitor interface {
	// VisitPre is called for each node before recursing into that subtree. Upon return, if recurse
	// is false, the visit will not recurse into the subtree (and VisitPost will not be called for
	// this node).
	//
	// The returned Expr replaces the visited expression and can be used for rewriting expressions.
	// The function should NOT modify nodes in-place; it should make copies of nodes. The Walk
	// infrastructure will automatically make copies of parents as needed.
	VisitPre(expr Expr) (recurse bool, newExpr Expr)

	// VisitPost is called for each node after recursing into the subtree. The returned Expr
	// replaces the visited expression and can be used for rewriting expressions.
	//
	// The returned Expr replaces the visited expression and can be used for rewriting expressions.
	// The function should NOT modify nodes in-place; it should make and return copies of nodes. The
	// Walk infrastructure will automatically make copies of parents as needed.
	VisitPost(expr Expr) (newNode Expr)
}

Visitor defines methods that are called for nodes during an expression or statement walk.

type WalkableStmt

type WalkableStmt interface {
	Statement
	WalkStmt(Visitor) Statement
}

WalkableStmt is implemented by statements that can appear inside an expression (selects) or we want to start a walk from (using WalkStmt).

type When

type When struct {
	Cond Expr
	Val  Expr
}

When represents a WHEN sub-expression.

func (*When) Format

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

Format implements the NodeFormatter interface.

type Where

type Where struct {
	Type string
	Expr Expr
}

Where represents a WHERE or HAVING clause.

func (*Where) Format

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

Format implements the NodeFormatter interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL