parser

package
v0.0.0-...-bf013fd Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2016 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Distinct funcType
	All
)

FuncExpr.Type

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

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

View Source
const SAVEPOINT = 57536
View Source
const SCONST = 57348
View Source
const SEARCH = 57537
View Source
const SECOND = 57538
View Source
const SELECT = 57539
View Source
const SERIALIZABLE = 57540
View Source
const SESSION = 57541
View Source
const SESSION_USER = 57542
View Source
const SET = 57543
View Source
const SHOW = 57544
View Source
const SIMILAR = 57545
View Source
const SIMPLE = 57546
View Source
const SMALLINT = 57547
View Source
const SNAPSHOT = 57548
View Source
const SOME = 57549
View Source
const SQL = 57550
View Source
const START = 57551
View Source
const STORING = 57554
View Source
const STRICT = 57552
View Source
const STRING = 57553
View Source
const SUBSTRING = 57555
View Source
const SYMMETRIC = 57556
View Source
const TABLE = 57557
View Source
const TABLES = 57558
View Source
const TEXT = 57559
View Source
const THEN = 57560
View Source
const TIME = 57561
View Source
const TIMESTAMP = 57562
View Source
const TO = 57563
View Source
const TRAILING = 57564
View Source
const TRANSACTION = 57565
View Source
const TREAT = 57566
View Source
const TRIM = 57567
View Source
const TRUE = 57568
View Source
const TRUNCATE = 57569
View Source
const TYPE = 57570
View Source
const TYPECAST = 57352
View Source
const UMINUS = 57597
View Source
const UNBOUNDED = 57571
View Source
const UNCOMMITTED = 57572
View Source
const UNION = 57573
View Source
const UNIQUE = 57574
View Source
const UNKNOWN = 57575
View Source
const UPDATE = 57576
View Source
const USER = 57577
View Source
const USING = 57578
View Source
const VALID = 57579
View Source
const VALIDATE = 57580
View Source
const VALUE = 57581
View Source
const VALUES = 57582
View Source
const VARCHAR = 57583
View Source
const VARIADIC = 57584
View Source
const VARYING = 57585
View Source
const WHEN = 57586
View Source
const WHERE = 57587
View Source
const WINDOW = 57588
View Source
const WITH = 57589
View Source
const WITHIN = 57590
View Source
const WITHOUT = 57591
View Source
const WITH_LA = 57595
View Source
const YEAR = 57592
View Source
const ZONE = 57593

Variables

This section is empty.

Functions

func ContainsVars

func ContainsVars(expr Expr) bool

ContainsVars returns true if the expression contains any variables.

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) *roachpb.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 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) String

func (a AliasClause) String() string

type AliasedTableExpr

type AliasedTableExpr struct {
	Expr SimpleTableExpr
	As   AliasClause
}

AliasedTableExpr represents a table expression coupled with an optional alias.

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

func (node *AlterTableAddColumn) String() string

type AlterTableAddConstraint

type AlterTableAddConstraint struct {
	ConstraintDef ConstraintTableDef
}

AlterTableAddConstraint represents an ADD CONSTRAINT command.

func (*AlterTableAddConstraint) String

func (node *AlterTableAddConstraint) String() string

type AlterTableCmd

type AlterTableCmd interface {
	// 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) String

func (node AlterTableCmds) String() string

type AlterTableDropColumn

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

AlterTableDropColumn represents a DROP COLUMN command.

func (*AlterTableDropColumn) String

func (node *AlterTableDropColumn) String() string

type AlterTableDropConstraint

type AlterTableDropConstraint struct {
	IfExists   bool
	Constraint string
}

AlterTableDropConstraint represents a DROP CONSTRAINT command.

func (*AlterTableDropConstraint) String

func (node *AlterTableDropConstraint) String() string

type AndExpr

type AndExpr struct {
	Left, Right Expr
}

AndExpr represents an AND expression.

func (*AndExpr) Eval

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

Eval implements the Expr interface.

func (*AndExpr) String

func (node *AndExpr) String() string

func (*AndExpr) TypeCheck

func (expr *AndExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*AndExpr) Walk

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

Walk implements the Expr interface.

type Args

type Args interface {
	Arg(name string) (Datum, bool)
}

Args defines the interface for retrieving arguments. Return false for the second return value if the argument cannot be found.

type Array

type Array struct {
	Exprs Exprs
}

Array represents an array constructor.

func (Array) Eval

func (t Array) Eval(_ EvalContext) (Datum, error)

Eval implements the Expr interface.

func (*Array) String

func (node *Array) String() string

func (*Array) TypeCheck

func (expr *Array) TypeCheck(args MapArgs) (Datum, 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) String

func (a *ArrayIndirection) String() string

type BeginTransaction

type BeginTransaction struct {
	Isolation    IsolationLevel
	UserPriority UserPriority
}

BeginTransaction represents a BEGIN statement

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 (node *BeginTransaction) String() string

type BinaryExpr

type BinaryExpr struct {
	Operator    BinaryOp
	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 Expr interface.

func (*BinaryExpr) String

func (node *BinaryExpr) String() string

func (*BinaryExpr) TypeCheck

func (expr *BinaryExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*BinaryExpr) Walk

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

Walk implements the Expr interface.

type BinaryOp

type BinaryOp int

BinaryOp represents a binary operator.

const (
	Bitand BinaryOp = iota
	Bitor
	Bitxor
	Plus
	Minus
	Mult
	Div
	Mod
	Concat
	LShift
	RShift
)

BinaryExpr.Operator

func (BinaryOp) String

func (i BinaryOp) String() string

type BoolType

type BoolType struct {
	Name string
}

BoolType represents a BOOLEAN type.

func (*BoolType) String

func (node *BoolType) String() string

type BytesType

type BytesType struct {
	Name string
}

BytesType represents a BYTES or BLOB type.

func (*BytesType) String

func (node *BytesType) String() string

type CaseExpr

type CaseExpr struct {
	Expr  Expr
	Whens []*When
	Else  Expr
}

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

func (*CaseExpr) String

func (node *CaseExpr) String() string

func (*CaseExpr) TypeCheck

func (expr *CaseExpr) TypeCheck(args MapArgs) (Datum, 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
}

CastExpr represents a CAST(expr AS type) expression.

func (*CastExpr) Eval

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

Eval implements the Expr interface.

func (*CastExpr) String

func (n *CastExpr) String() string

func (*CastExpr) TypeCheck

func (expr *CastExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*CastExpr) Walk

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

Walk implements the Expr interface.

type CoalesceExpr

type CoalesceExpr struct {
	Name  string
	Exprs Exprs
}

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

func (*CoalesceExpr) String

func (node *CoalesceExpr) String() string

func (*CoalesceExpr) TypeCheck

func (expr *CoalesceExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*CoalesceExpr) Walk

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

Walk implements the Expr interface.

type ColumnDefault

type ColumnDefault struct {
	Expr Expr
}

ColumnDefault represents a DEFAULT clause for a 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    Nullability
	PrimaryKey  bool
	Unique      bool
	DefaultExpr Expr
}

ColumnTableDef represents a column definition within a CREATE TABLE statement.

func (*ColumnTableDef) String

func (node *ColumnTableDef) String() string

type ColumnType

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

ColumnType represents a type in a column definition.

type CommitTransaction

type CommitTransaction struct{}

CommitTransaction represents a COMMIT statement.

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 (node *CommitTransaction) String() string

type ComparisonExpr

type ComparisonExpr struct {
	Operator    ComparisonOp
	Left, Right Expr
	// contains filtered or unexported fields
}

ComparisonExpr represents a two-value comparison expression.

func (*ComparisonExpr) Eval

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

Eval implements the Expr interface.

func (*ComparisonExpr) String

func (node *ComparisonExpr) String() string

func (*ComparisonExpr) TypeCheck

func (expr *ComparisonExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*ComparisonExpr) Walk

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

Walk implements the Expr interface.

type ComparisonOp

type ComparisonOp int

ComparisonOp represents a binary operator.

const (
	EQ ComparisonOp = iota
	LT
	GT
	LE
	GE
	NE
	In
	NotIn
	Like
	NotLike
	SimilarTo
	NotSimilarTo
	IsDistinctFrom
	IsNotDistinctFrom
	Is
	IsNot
)

ComparisonExpr.Operator

func (ComparisonOp) String

func (i ComparisonOp) String() string

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
}

CreateDatabase represents a CREATE DATABASE statement.

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 (node *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
}

CreateIndex represents a CREATE INDEX statement.

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 (node *CreateIndex) String() string

type CreateTable

type CreateTable struct {
	IfNotExists bool
	Table       *QualifiedName
	Defs        TableDefs
}

CreateTable represents a CREATE TABLE statement.

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 (node *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 (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 Expr interface.

func (DBool) HasNext

func (d DBool) HasNext() bool

HasNext implements the Datum interface.

func (DBool) HasPrev

func (d 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 (d DBool) Next() Datum

Next implements the Datum interface.

func (DBool) Prev

func (d DBool) Prev() Datum

Prev implements the Datum interface.

func (DBool) String

func (d DBool) String() string

func (DBool) Type

func (d DBool) Type() string

Type implements the Datum interface.

func (DBool) TypeCheck

func (expr DBool) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 (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 Expr interface.

func (DBytes) HasNext

func (d DBytes) HasNext() bool

HasNext implements the Datum interface.

func (DBytes) HasPrev

func (d DBytes) HasPrev() bool

HasPrev implements the Datum interface.

func (DBytes) IsMax

func (d 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) String

func (d DBytes) String() string

func (DBytes) Type

func (d DBytes) Type() string

Type implements the Datum interface.

func (DBytes) TypeCheck

func (expr DBytes) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 ParseDate

func ParseDate(s DString) (DDate, error)

ParseDate parses a date.

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

func (DDate) HasNext

func (d DDate) HasNext() bool

HasNext implements the Datum interface.

func (DDate) HasPrev

func (d 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) String

func (d DDate) String() string

func (DDate) Type

func (d DDate) Type() string

Type implements the Datum interface.

func (DDate) TypeCheck

func (expr DDate) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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.

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

func (*DDecimal) HasNext

func (d *DDecimal) HasNext() bool

HasNext implements the Datum interface.

func (*DDecimal) HasPrev

func (d *DDecimal) HasPrev() bool

HasPrev implements the Datum interface.

func (*DDecimal) IsMax

func (d *DDecimal) IsMax() bool

IsMax implements the Datum interface.

func (*DDecimal) IsMin

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

func (d *DDecimal) String() string

func (*DDecimal) Type

func (d *DDecimal) Type() string

Type implements the Datum interface.

func (DDecimal) TypeCheck

func (expr DDecimal) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 (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 Expr interface.

func (DFloat) HasNext

func (d DFloat) HasNext() bool

HasNext implements the Datum interface.

func (DFloat) HasPrev

func (d 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) String

func (d DFloat) String() string

func (DFloat) Type

func (d DFloat) Type() string

Type implements the Datum interface.

func (DFloat) TypeCheck

func (expr DFloat) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 (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 Expr interface.

func (DInt) HasNext

func (d DInt) HasNext() bool

HasNext implements the Datum interface.

func (DInt) HasPrev

func (d 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) String

func (d DInt) String() string

func (DInt) Type

func (d DInt) Type() string

Type implements the Datum interface.

func (DInt) TypeCheck

func (expr DInt) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 (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 Expr interface.

func (DInterval) HasNext

func (d DInterval) HasNext() bool

HasNext implements the Datum interface.

func (DInterval) HasPrev

func (d 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) String

func (d DInterval) String() string

String implements the Datum interface.

func (DInterval) Type

func (d DInterval) Type() string

Type implements the Datum interface.

func (DInterval) TypeCheck

func (expr DInterval) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 DString

type DString string

DString is the string Datum.

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

func (DString) HasNext

func (d DString) HasNext() bool

HasNext implements the Datum interface.

func (DString) HasPrev

func (d DString) HasPrev() bool

HasPrev implements the Datum interface.

func (DString) IsMax

func (d 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) String

func (d DString) String() string

func (DString) Type

func (d DString) Type() string

Type implements the Datum interface.

func (DString) TypeCheck

func (expr DString) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 (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 Expr interface.

func (DTimestamp) HasNext

func (d DTimestamp) HasNext() bool

HasNext implements the Datum interface.

func (DTimestamp) HasPrev

func (d 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) String

func (d DTimestamp) String() string

func (DTimestamp) Type

func (d DTimestamp) Type() string

Type implements the Datum interface.

func (DTimestamp) TypeCheck

func (expr DTimestamp) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 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 Expr 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 (d DTuple) IsMax() bool

IsMax implements the Datum interface.

func (DTuple) IsMin

func (d 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) String

func (d DTuple) String() string

func (DTuple) Swap

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

func (DTuple) Type

func (d DTuple) Type() string

Type implements the Datum interface.

func (DTuple) TypeCheck

func (expr DTuple) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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 DValArg

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

DValArg is the named bind var argument Datum.

func (DValArg) Compare

func (d DValArg) Compare(other Datum) int

Compare implements the Datum interface.

func (DValArg) Eval

func (t DValArg) Eval(_ EvalContext) (Datum, error)

Eval implements the Expr interface.

func (DValArg) HasNext

func (d DValArg) HasNext() bool

HasNext implements the Datum interface.

func (DValArg) HasPrev

func (d DValArg) HasPrev() bool

HasPrev implements the Datum interface.

func (DValArg) IsMax

func (DValArg) IsMax() bool

IsMax implements the Datum interface.

func (DValArg) IsMin

func (DValArg) IsMin() bool

IsMin implements the Datum interface.

func (DValArg) Next

func (d DValArg) Next() Datum

Next implements the Datum interface.

func (DValArg) Prev

func (d DValArg) Prev() Datum

Prev implements the Datum interface.

func (DValArg) String

func (d DValArg) String() string

func (DValArg) Type

func (DValArg) Type() string

Type implements the Datum interface.

func (DValArg) TypeCheck

func (expr DValArg) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (DValArg) TypeEqual

func (d DValArg) TypeEqual(other Datum) bool

TypeEqual implements the Datum interface.

func (DValArg) Variable

func (DValArg) Variable()

Variable implements the VariableExpr interface.

func (DValArg) Walk

func (expr DValArg) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DateType

type DateType struct {
}

DateType represents a DATE type.

func (*DateType) String

func (node *DateType) String() string

type Datum

type Datum interface {
	Expr
	// 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.

TODO(nvanbenschoten) It might be worth it in the future to make all Datum implementations receive on pointer types to provide more control over memory allocations when packaging and unpackaging concrete types to and from their Datum interface. This would allow us to make optimizations in terms of shared buffer preallocations.

var (
	// DummyBool is a placeholder DBool value.
	DummyBool Datum = DBool(false)
	// DummyInt is a placeholder DInt value.
	DummyInt Datum = DInt(0)
	// DummyFloat is a placeholder DFloat value.
	DummyFloat Datum = DFloat(0)
	// DummyDecimal is a placeholder DDecimal value.
	DummyDecimal Datum = &DDecimal{}
	// DummyString is a placeholder DString value.
	DummyString Datum = DString("")
	// DummyBytes is a placeholder DBytes value.
	DummyBytes Datum = DBytes("")
	// DummyDate is a placeholder DDate value.
	DummyDate Datum = DDate(0)
	// DummyTimestamp is a placeholder DTimestamp value.
	DummyTimestamp Datum = DTimestamp{}
	// DummyInterval is a placeholder DInterval value.
	DummyInterval Datum = DInterval{}

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

type DecimalType

type DecimalType struct {
	Name  string
	Prec  int
	Scale int
}

DecimalType represents a DECIMAL or NUMERIC type.

func (*DecimalType) String

func (node *DecimalType) String() string

type DefaultVal

type DefaultVal struct{}

DefaultVal represents the DEFAULT expression.

func (DefaultVal) Eval

func (t DefaultVal) Eval(_ EvalContext) (Datum, error)

Eval implements the Expr interface.

func (DefaultVal) String

func (node DefaultVal) String() string

func (DefaultVal) TypeCheck

func (expr DefaultVal) TypeCheck(args MapArgs) (Datum, 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) 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 (node *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 DropDatabase

type DropDatabase struct {
	Name     Name
	IfExists bool
}

DropDatabase represents a DROP DATABASE statement.

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 (node *DropDatabase) String() string

type DropIndex

type DropIndex struct {
	Names    QualifiedNames
	IfExists bool
}

DropIndex represents a DROP INDEX statement.

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 (node *DropIndex) String() string

type DropTable

type DropTable struct {
	Names    QualifiedNames
	IfExists bool
}

DropTable represents a DROP TABLE statement.

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 (node *DropTable) String() string

type EvalContext

type EvalContext struct {
	NodeID roachpb.NodeID

	ReCache     *RegexpCache
	GetLocation func() (*time.Location, error)
	Args        MapArgs

	// 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
	// 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) 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() roachpb.Timestamp

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(expr Expr) (Expr, error)

NormalizeExpr normalizes an expression, simplifying where possible, but guaranteeing that the result of evaluating the expression is unchanged. Example normalizations:

(a)                   -> a
ROW(a, b, c)          -> (a, b, c)
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) ParseTimestamp

func (ctx EvalContext) ParseTimestamp(s DString) (DTimestamp, error)

ParseTimestamp parses the timestamp.

func (*EvalContext) SetStmtTimestamp

func (ctx *EvalContext) SetStmtTimestamp(ts roachpb.Timestamp)

SetStmtTimestamp sets the corresponding timestamp in the EvalContext.

func (*EvalContext) SetTxnTimestamp

func (ctx *EvalContext) SetTxnTimestamp(ts roachpb.Timestamp)

SetTxnTimestamp sets the corresponding timestamp in the EvalContext.

type ExistsExpr

type ExistsExpr struct {
	Subquery Expr
}

ExistsExpr represents an EXISTS expression.

func (*ExistsExpr) Eval

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

Eval implements the Expr interface.

func (*ExistsExpr) String

func (node *ExistsExpr) String() string

func (*ExistsExpr) TypeCheck

func (expr *ExistsExpr) TypeCheck(args MapArgs) (Datum, 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) 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 (node *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
	// 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 returns the zero value of the expression's type, or an
	// error if the expression doesn't type-check. args maps bind var argument
	// names to types.
	TypeCheck(args MapArgs) (Datum, error)
	// 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: ValArg, QualifiedName or Subquery. These nodes
	// should be replaced prior to expression evaluation by an appropriate
	// WalkExpr. For example, ValArg should be replace by the argument passed from
	// the client.
	Eval(EvalContext) (Datum, error)
}

Expr represents an expression.

func ParseExprTraditional

func ParseExprTraditional(sql string) (Expr, error)

ParseExprTraditional is a short-hand for parseExpr(sql, Traditional)

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 (Exprs) String

func (node Exprs) String() string

type FloatType

type FloatType struct {
	Name string
	Prec int
}

FloatType represents a REAL, DOUBLE or FLOAT type.

func (*FloatType) String

func (node *FloatType) String() string

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

func (*FuncExpr) String

func (node *FuncExpr) String() string

func (*FuncExpr) TypeCheck

func (expr *FuncExpr) TypeCheck(args MapArgs) (Datum, 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) 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 (node *Grant) String() string

type GroupBy

type GroupBy []Expr

GroupBy represents a GROUP BY clause.

func (GroupBy) String

func (node GroupBy) String() string

type IfExpr

type IfExpr struct {
	Cond Expr
	True Expr
	Else Expr
}

IfExpr represents an IF expression.

func (*IfExpr) Eval

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

Eval implements the Expr interface.

func (*IfExpr) String

func (node *IfExpr) String() string

func (*IfExpr) TypeCheck

func (expr *IfExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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

func (node IndexElem) String() string

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

func (l IndexElemList) String() string

String formats the contained names as a comma-separated, escaped string.

type IndexIndirection

type IndexIndirection Name

IndexIndirection represents ":<name>" in an indirection expression.

func (IndexIndirection) String

func (n IndexIndirection) String() string

type IndexTableDef

type IndexTableDef struct {
	Name    Name
	Columns IndexElemList
	Storing NameList
}

IndexTableDef represents an index definition within a CREATE TABLE statement.

func (*IndexTableDef) String

func (node *IndexTableDef) String() string

type Indirection

type Indirection []IndirectionElem

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

func (Indirection) String

func (i Indirection) String() string

type IndirectionElem

type IndirectionElem interface {
	String() string
	// contains filtered or unexported methods
}

IndirectionElem is a single element in an indirection expression.

type Insert

type Insert struct {
	Table     *QualifiedName
	Columns   QualifiedNames
	Rows      *Select
	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) 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 (node *Insert) String() string

func (*Insert) WalkStmt

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

WalkStmt is part of the WalkableStmt interface.

type IntType

type IntType struct {
	Name string
	N    int
}

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

func (*IntType) String

func (node *IntType) String() string

type IntVal

type IntVal struct {
	Val int64
	Str string
}

IntVal represents an integer.

func (*IntVal) Eval

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

Eval implements the Expr interface.

func (*IntVal) String

func (node *IntVal) String() string

func (IntVal) TypeCheck

func (expr IntVal) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*IntVal) Walk

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

Walk implements the Expr interface.

type IntervalType

type IntervalType struct {
}

IntervalType represents an INTERVAL type

func (*IntervalType) String

func (node *IntervalType) String() string

type IsOfTypeExpr

type IsOfTypeExpr struct {
	Not   bool
	Expr  Expr
	Types []ColumnType
}

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

func (*IsOfTypeExpr) Eval

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

Eval implements the Expr interface.

func (*IsOfTypeExpr) String

func (node *IsOfTypeExpr) String() string

func (*IsOfTypeExpr) TypeCheck

func (expr *IsOfTypeExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*IsOfTypeExpr) Walk

func (expr *IsOfTypeExpr) Walk(_ 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 {
	// 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) String

func (node *JoinTableExpr) String() string

type Limit

type Limit struct {
	Offset, Count Expr
}

Limit represents a LIMIT clause.

func (*Limit) String

func (node *Limit) String() string

type MapArgs

type MapArgs map[string]Datum

MapArgs is an Args implementation which is used for the type inference necessary to support the postgres wire protocol. See various TypeCheck() implementations for details.

func (MapArgs) Arg

func (m MapArgs) Arg(name string) (Datum, bool)

Arg implements the Args interface.

func (MapArgs) SetInferredType

func (m MapArgs) SetInferredType(d, typ Datum) (set Datum, err error)

SetInferredType sets the bind var argument d to the type typ in m. If m is nil or d is not a DValArg, nil is returned. If the bind var argument is set, typ is returned. An error is returned if typ cannot be set because a different type is already present.

type Name

type Name string

A Name is an SQL identifier.

func (Name) String

func (n Name) String() string

String formats an SQL identifier, applying proper escaping rules.

type NameIndirection

type NameIndirection Name

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

func (NameIndirection) String

func (n NameIndirection) String() string

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

func (l NameList) String() string

String formats the contained names as a comma-separated, escaped string.

type NotExpr

type NotExpr struct {
	Expr Expr
}

NotExpr represents a NOT expression.

func (*NotExpr) Eval

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

Eval implements the Expr interface.

func (*NotExpr) String

func (node *NotExpr) String() string

func (*NotExpr) TypeCheck

func (expr *NotExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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
}

NullIfExpr represents a NULLIF expression.

func (*NullIfExpr) Eval

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

Eval implements the Expr interface.

func (*NullIfExpr) String

func (node *NullIfExpr) String() string

func (*NullIfExpr) TypeCheck

func (expr *NullIfExpr) TypeCheck(args MapArgs) (Datum, 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 string

NumVal represents a number.

func (NumVal) Eval

func (t NumVal) Eval(_ EvalContext) (Datum, error)

Eval implements the Expr interface.

func (NumVal) String

func (node NumVal) String() string

func (NumVal) TypeCheck

func (expr NumVal) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (NumVal) Walk

func (expr NumVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type OnJoinCond

type OnJoinCond struct {
	Expr Expr
}

OnJoinCond represents an ON join condition.

func (*OnJoinCond) String

func (node *OnJoinCond) String() string

type OrExpr

type OrExpr struct {
	Left, Right Expr
}

OrExpr represents an OR expression.

func (*OrExpr) Eval

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

Eval implements the Expr interface.

func (*OrExpr) String

func (node *OrExpr) String() string

func (*OrExpr) TypeCheck

func (expr *OrExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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

func (node *Order) String() string

type OrderBy

type OrderBy []*Order

OrderBy represents an ORDER By clause.

func (OrderBy) String

func (node OrderBy) String() string

type OverlayExpr

type OverlayExpr struct {
	FuncExpr
}

OverlayExpr represents an overlay function call.

func (*OverlayExpr) String

func (node *OverlayExpr) String() string

type ParenExpr

type ParenExpr struct {
	Expr
}

ParenExpr represents a parenthesized expression.

func (*ParenExpr) String

func (node *ParenExpr) String() string

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

func (p *Parser) NormalizeExpr(ctx EvalContext, expr Expr) (Expr, 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 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 (n *QualifiedName) ClearString()

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

func (*QualifiedName) Column

func (n *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 (n *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 (t *QualifiedName) Eval(_ EvalContext) (Datum, error)

Eval implements the Expr interface.

func (*QualifiedName) Index

func (n *QualifiedName) Index() string

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

func (*QualifiedName) IsStar

func (n *QualifiedName) IsStar() bool

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

func (*QualifiedName) NormalizeColumnName

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

func (n *QualifiedName) String() string

func (*QualifiedName) Table

func (n *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(args MapArgs) (Datum, 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) String

func (n QualifiedNames) String() string

type RangeCond

type RangeCond struct {
	Not      bool
	Left     Expr
	From, To Expr
}

RangeCond represents a BETWEEN or a NOT BETWEEN expression.

func (*RangeCond) Eval

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

Eval implements the Expr interface.

func (*RangeCond) String

func (node *RangeCond) String() string

func (*RangeCond) TypeCheck

func (expr *RangeCond) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

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) 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 (node *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) 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 (node *RenameColumn) String() string

type RenameDatabase

type RenameDatabase struct {
	Name    Name
	NewName Name
}

RenameDatabase represents a RENAME DATABASE statement.

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 (node *RenameDatabase) String() string

type RenameIndex

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

RenameIndex represents a RENAME INDEX statement.

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 (node *RenameIndex) String() string

type RenameTable

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

RenameTable represents a RENAME TABLE statement.

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 (node *RenameTable) String() string

type ReturningExprs

type ReturningExprs SelectExprs

ReturningExprs represents RETURNING expressions.

func (ReturningExprs) StatementType

func (r ReturningExprs) StatementType() StatementType

StatementType implements the Statement interface.

func (ReturningExprs) String

func (r ReturningExprs) String() string

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) 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 (node *Revoke) String() string

type RollbackToSavepoint

type RollbackToSavepoint struct {
	Savepoint string
}

RollbackToSavepoint represents a ROLLBACK TO SAVEPOINT <name> statement.

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 (node *RollbackToSavepoint) String() string

type RollbackTransaction

type RollbackTransaction struct{}

RollbackTransaction represents a ROLLBACK statement.

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 (node *RollbackTransaction) String() string

type Row

type Row struct {
	Exprs Exprs
}

Row represents a parenthesized list of expressions. Similar to Tuple except in how it is textually represented.

func (*Row) Eval

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

Eval implements the Expr interface.

func (*Row) String

func (node *Row) String() string

func (*Row) TypeCheck

func (expr *Row) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*Row) Walk

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

Walk implements the Expr interface.

type Savepoint

type Savepoint struct {
	Name string
}

Savepoint represents a SAVEPOINT <name> statement.

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 (node *Savepoint) String() string

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

func (node SelectExpr) String() string

type SelectExprs

type SelectExprs []SelectExpr

SelectExprs represents SELECT expressions.

func (SelectExprs) String

func (node SelectExprs) String() string

type SelectStatement

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

SelectStatement any SELECT statement.

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) 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 (node *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) 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 (node *SetDefaultIsolation) String() string

type SetTimeZone

type SetTimeZone struct {
	Value Expr
}

SetTimeZone represents a SET TIME ZONE statement.

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 (node *SetTimeZone) String() string

type SetTransaction

type SetTransaction struct {
	Isolation    IsolationLevel
	UserPriority UserPriority
}

SetTransaction represents a SET TRANSACTION statement.

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 (node *SetTransaction) String() string

type Show

type Show struct {
	Name string
}

Show represents a SHOW statement.

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 (node *Show) String() string

type ShowColumns

type ShowColumns struct {
	Table *QualifiedName
}

ShowColumns represents a SHOW COLUMNS statement.

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 (node *ShowColumns) String() string

type ShowDatabases

type ShowDatabases struct {
}

ShowDatabases represents a SHOW DATABASES statement.

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 (node *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) 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 (node *ShowGrants) String() string

type ShowIndex

type ShowIndex struct {
	Table *QualifiedName
}

ShowIndex represents a SHOW INDEX statement.

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 (node *ShowIndex) String() string

type ShowTables

type ShowTables struct {
	Name *QualifiedName
}

ShowTables represents a SHOW TABLES statement.

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 (node *ShowTables) String() string

type SimpleTableExpr

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

SimpleTableExpr represents a simple table expression.

type StarIndirection

type StarIndirection string

StarIndirection represents ".*" in an indirection expression.

func (StarIndirection) String

func (s StarIndirection) String() string

type Statement

type Statement interface {
	fmt.Stringer
	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 FillArgs

func FillArgs(stmt Statement, args Args) (Statement, error)

FillArgs replaces any placeholder nodes in the expression with arguments supplied with the query.

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

type StringType

type StringType struct {
	Name string
	N    int
}

StringType represents a STRING, CHAR or VARCHAR type.

func (*StringType) String

func (node *StringType) String() string

type Subquery

type Subquery struct {
	Select SelectStatement
}

Subquery represents a subquery.

func (*Subquery) Eval

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

Eval implements the Expr interface.

func (*Subquery) String

func (node *Subquery) String() string

func (*Subquery) TypeCheck

func (expr *Subquery) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr 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 {
	// contains filtered or unexported methods
}

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

type TableDefs

type TableDefs []TableDef

TableDefs represents a list of table definitions.

func (TableDefs) String

func (node TableDefs) String() string

type TableExpr

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

TableExpr represents a table expression.

type TableExprs

type TableExprs []TableExpr

TableExprs represents a list of table expressions.

func (TableExprs) String

func (node TableExprs) String() string

type TargetList

type TargetList struct {
	Databases NameList
	Tables    QualifiedNames
}

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

func (TargetList) String

func (tl TargetList) String() string

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 TimestampType

type TimestampType struct {
}

TimestampType represents a TIMESTAMP type.

func (*TimestampType) String

func (node *TimestampType) String() string

type Truncate

type Truncate struct {
	Tables QualifiedNames
}

Truncate represents a TRUNCATE statement.

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 (node *Truncate) String() string

type Tuple

type Tuple struct {
	Exprs Exprs
}

Tuple represents a parenthesized list of expressions.

func (*Tuple) Eval

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

Eval implements the Expr interface.

func (*Tuple) String

func (node *Tuple) String() string

func (*Tuple) TypeCheck

func (expr *Tuple) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*Tuple) Walk

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

Walk implements the Expr interface.

type UnaryExpr

type UnaryExpr struct {
	Operator UnaryOp
	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 Expr interface.

func (*UnaryExpr) String

func (node *UnaryExpr) String() string

func (*UnaryExpr) TypeCheck

func (expr *UnaryExpr) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (*UnaryExpr) Walk

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

Walk implements the Expr interface.

type UnaryOp

type UnaryOp int

UnaryOp represents a unary operator.

const (
	UnaryPlus UnaryOp = iota
	UnaryMinus
	UnaryComplement
)

UnaryExpr.Operator

func (UnaryOp) String

func (i UnaryOp) String() string

type UnionClause

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

UnionClause represents a UNION statement.

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

func (node *UniqueConstraintTableDef) String() string

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

func (node *UpdateExpr) String() string

type UpdateExprs

type UpdateExprs []*UpdateExpr

UpdateExprs represents a list of update expressions.

func (UpdateExprs) String

func (node UpdateExprs) String() string

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

func (node *UsingJoinCond) String() string

type ValArg

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

ValArg represents a named bind var argument.

func (ValArg) Eval

func (t ValArg) Eval(_ EvalContext) (Datum, error)

Eval implements the Expr interface.

func (ValArg) String

func (node ValArg) String() string

func (ValArg) TypeCheck

func (expr ValArg) TypeCheck(args MapArgs) (Datum, error)

TypeCheck implements the Expr interface.

func (ValArg) Variable

func (ValArg) Variable()

Variable implements the VariableExpr interface.

func (ValArg) Walk

func (expr ValArg) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type ValuesClause

type ValuesClause struct {
	Tuples []*Tuple
}

ValuesClause represents a VALUES clause.

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

func (node *When) String() string

type Where

type Where struct {
	Type string
	Expr Expr
}

Where represents a WHERE or HAVING clause.

func (*Where) String

func (node *Where) String() string

Jump to

Keyboard shortcuts

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