parser

package
v0.0.0-...-d6fed6f Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TargetDatabase TargetType = iota

	PrivilegeAll PrivilegeType = iota
	PrivilegeRead
	PrivilegeWrite
)

Enums for target and privilege types.

View Source
const ABORT = 57359
View Source
const ABSOLUTE = 57360
View Source
const ACCESS = 57361
View Source
const ACTION = 57362
View Source
const ADD = 57363
View Source
const ADMIN = 57364
View Source
const AFTER = 57365
View Source
const AGGREGATE = 57366
View Source
const ALL = 57367
View Source
const ALSO = 57368
View Source
const ALTER = 57369
View Source
const ALWAYS = 57370
View Source
const ANALYSE = 57371
View Source
const ANALYZE = 57372
View Source
const AND = 57373
View Source
const ANY = 57374
View Source
const ARRAY = 57375
View Source
const AS = 57376
View Source
const ASC = 57377
View Source
const ASSERTION = 57378
View Source
const ASSIGNMENT = 57379
View Source
const ASYMMETRIC = 57380
View Source
const AT = 57381
View Source
const ATTRIBUTE = 57382
View Source
const AUTHORIZATION = 57383
View Source
const BACKWARD = 57384
View Source
const BCONST = 57349
View Source
const BEFORE = 57385
View Source
const BEGIN = 57386
View Source
const BETWEEN = 57387
View Source
const BIGINT = 57388
View Source
const BINARY = 57389
View Source
const BIT = 57390
View Source
const BLOB = 57391
View Source
const BOOLEAN = 57392
View Source
const BOTH = 57393
View Source
const BY = 57394
View Source
const CACHE = 57395
View Source
const CALLED = 57396
View Source
const CASCADE = 57397
View Source
const CASCADED = 57398
View Source
const CASE = 57399
View Source
const CAST = 57400
View Source
const CHAIN = 57401
View Source
const CHAR = 57402
View Source
const CHARACTER = 57403
View Source
const CHARACTERISTICS = 57404
View Source
const CHECK = 57405
View Source
const CHECKPOINT = 57406
View Source
const CLASS = 57407
View Source
const CLOSE = 57408
View Source
const CLUSTER = 57409
View Source
const COALESCE = 57410
View Source
const COLLATE = 57411
View Source
const COLLATION = 57412
View Source
const COLUMN = 57413
View Source
const COLUMNS = 57414
View Source
const COMMENT = 57415
View Source
const COMMENTS = 57416
View Source
const COMMIT = 57417
View Source
const COMMITTED = 57418
View Source
const CONCAT = 57419
View Source
const CONCURRENTLY = 57420
View Source
const CONFIGURATION = 57421
View Source
const CONFLICT = 57422
View Source
const CONNECTION = 57423
View Source
const CONSTRAINT = 57424
View Source
const CONSTRAINTS = 57425
View Source
const CONTENT = 57426
View Source
const CONTINUE = 57427
View Source
const CONVERSION = 57428
View Source
const COPY = 57429
View Source
const COST = 57430
View Source
const CREATE = 57431
View Source
const CROSS = 57432
View Source
const CSV = 57433
View Source
const CUBE = 57434
View Source
const CURRENT = 57435
View Source
const CURRENT_CATALOG = 57436
View Source
const CURRENT_DATE = 57437
View Source
const CURRENT_ROLE = 57438
View Source
const CURRENT_TIME = 57439
View Source
const CURRENT_TIMESTAMP = 57440
View Source
const CURRENT_USER = 57441
View Source
const CURSOR = 57442
View Source
const CYCLE = 57443
View Source
const DATA = 57444
View Source
const DATABASE = 57445
View Source
const DATABASES = 57446
View Source
const DATE = 57447
View Source
const DAY = 57448
View Source
const DEALLOCATE = 57449
View Source
const DEC = 57450
View Source
const DECIMAL = 57451
View Source
const DECLARE = 57452
View Source
const DEFAULT = 57453
View Source
const DEFAULTS = 57454
View Source
const DEFERRABLE = 57455
View Source
const DEFERRED = 57456
View Source
const DEFINER = 57457
View Source
const DELETE = 57458
View Source
const DELIMITER = 57459
View Source
const DELIMITERS = 57460
View Source
const DESC = 57461
View Source
const DICTIONARY = 57462
View Source
const DISABLE = 57463
View Source
const DISCARD = 57464
View Source
const DISTINCT = 57465
View Source
const DO = 57466
View Source
const DOCUMENT = 57467
View Source
const DOMAIN = 57468
View Source
const DOT_DOT = 57354
View Source
const DOUBLE = 57469
View Source
const DROP = 57470
View Source
const EACH = 57471
View Source
const ELSE = 57472
View Source
const ENABLE = 57473
View Source
const ENCODING = 57474
View Source
const ENCRYPTED = 57475
View Source
const END = 57476
View Source
const ENUM = 57477
View Source
const ERROR = 57358
View Source
const ESCAPE = 57478
View Source
const EVENT = 57479
View Source
const EXCEPT = 57480
View Source
const EXCLUDE = 57481
View Source
const EXCLUDING = 57482
View Source
const EXCLUSIVE = 57483
View Source
const EXECUTE = 57484
View Source
const EXISTS = 57485
View Source
const EXPLAIN = 57486
View Source
const EXTENSION = 57487
View Source
const EXTERNAL = 57488
View Source
const EXTRACT = 57489
View Source
const FALSE = 57490
View Source
const FAMILY = 57491
View Source
const FCONST = 57347
View Source
const FETCH = 57492
View Source
const FILTER = 57493
View Source
const FIRST = 57494
View Source
const FLOAT = 57495
View Source
const FOLLOWING = 57496
View Source
const FOR = 57497
View Source
const FORCE = 57498
View Source
const FOREIGN = 57499
View Source
const FORWARD = 57500
View Source
const FREEZE = 57501
View Source
const FROM = 57502
View Source
const FULL = 57503
View Source
const FUNCTION = 57504
View Source
const FUNCTIONS = 57505
View Source
const GLOBAL = 57506
View Source
const GRANT = 57507
View Source
const GRANTED = 57508
View Source
const GRANTS = 57509
View Source
const GREATER_EQUALS = 57356
View Source
const GREATEST = 57510
View Source
const GROUP = 57511
View Source
const GROUPING = 57512
View Source
const HANDLER = 57513
View Source
const HAVING = 57514
View Source
const HEADER = 57515
View Source
const HOLD = 57516
View Source
const HOUR = 57517
View Source
const ICONST = 57351
View Source
const IDENT = 57346
View Source
const IDENTITY = 57518
View Source
const IF = 57519
View Source
const IMMEDIATE = 57520
View Source
const IMMUTABLE = 57521
View Source
const IMPLICIT = 57522
View Source
const IMPORT = 57523
View Source
const IN = 57524
View Source
const INCLUDING = 57525
View Source
const INCREMENT = 57526
View Source
const INDEX = 57527
View Source
const INDEXES = 57528
View Source
const INHERIT = 57529
View Source
const INHERITS = 57530
View Source
const INITIALLY = 57531
View Source
const INLINE = 57532
View Source
const INNER = 57533
View Source
const INOUT = 57534
View Source
const INPUT = 57535
View Source
const INSENSITIVE = 57536
View Source
const INSERT = 57537
View Source
const INSTEAD = 57538
View Source
const INT = 57539
View Source
const INTEGER = 57540
View Source
const INTERSECT = 57541
View Source
const INTERVAL = 57542
View Source
const INTO = 57543
View Source
const INVOKER = 57544
View Source
const IS = 57545
View Source
const ISOLATION = 57546
View Source
const JOIN = 57547
View Source
const KEY = 57548
View Source
const LABEL = 57549
View Source
const LANGUAGE = 57550
View Source
const LARGE = 57551
View Source
const LAST = 57552
View Source
const LATERAL = 57553
View Source
const LEADING = 57554
View Source
const LEAKPROOF = 57555
View Source
const LEAST = 57556
View Source
const LEFT = 57557
View Source
const LESS_EQUALS = 57355
View Source
const LEVEL = 57558
View Source
const LIKE = 57559
View Source
const LIMIT = 57560
View Source
const LISTEN = 57561
View Source
const LOAD = 57562
View Source
const LOCAL = 57563
View Source
const LOCALTIME = 57564
View Source
const LOCALTIMESTAMP = 57565
View Source
const LOCATION = 57566
View Source
const LOCK = 57567
View Source
const LOCKED = 57568
View Source
const LOGGED = 57569
View Source
const MAPPING = 57570
View Source
const MATCH = 57571
View Source
const MATERIALIZED = 57572
View Source
const MAXVALUE = 57573
View Source
const MINUTE = 57574
View Source
const MINVALUE = 57575
View Source
const MODE = 57576
View Source
const MONTH = 57577
View Source
const MOVE = 57578
View Source
const NAME = 57579
View Source
const NAMES = 57580
View Source
const NATIONAL = 57581
View Source
const NATURAL = 57582
View Source
const NCHAR = 57583
View Source
const NEXT = 57584
View Source
const NO = 57585
View Source
const NONE = 57586
View Source
const NOT = 57587
View Source
const NOTHING = 57588
View Source
const NOTIFY = 57589
View Source
const NOT_EQUALS = 57357
View Source
const NOT_LA = 57752
View Source
const NOWAIT = 57590
View Source
const NULL = 57591
View Source
const NULLIF = 57592
View Source
const NULLS = 57593
View Source
const NULLS_LA = 57753
View Source
const NUMERIC = 57594
View Source
const OBJECT = 57595
View Source
const OF = 57596
View Source
const OFF = 57597
View Source
const OFFSET = 57598
View Source
const OIDS = 57599
View Source
const ON = 57600
View Source
const ONLY = 57601
View Source
const OPTION = 57602
View Source
const OPTIONS = 57603
View Source
const OR = 57604
View Source
const ORDER = 57605
View Source
const ORDINALITY = 57606
View Source
const OUT = 57607
View Source
const OUTER = 57608
View Source
const OVER = 57609
View Source
const OVERLAPS = 57610
View Source
const OVERLAY = 57611
View Source
const OWNED = 57612
View Source
const OWNER = 57613
View Source
const PARAM = 57352
View Source
const PARSER = 57614
View Source
const PARTIAL = 57615
View Source
const PARTITION = 57616
View Source
const PASSING = 57617
View Source
const PASSWORD = 57618
View Source
const PLACING = 57619
View Source
const PLANS = 57620
View Source
const POLICY = 57621
View Source
const POSITION = 57622
View Source
const POSTFIXOP = 57755
View Source
const PRECEDING = 57623
View Source
const PRECISION = 57624
View Source
const PREPARE = 57626
View Source
const PREPARED = 57627
View Source
const PRESERVE = 57625
View Source
const PRIMARY = 57628
View Source
const PRIOR = 57629
View Source
const PRIVILEGES = 57630
View Source
const PROCEDURAL = 57631
View Source
const PROCEDURE = 57632
View Source
const PROGRAM = 57633
View Source
const QUOTE = 57634
View Source
const RANGE = 57635
View Source
const READ = 57636
View Source
const REAL = 57637
View Source
const REASSIGN = 57638
View Source
const RECHECK = 57639
View Source
const RECURSIVE = 57640
View Source
const REF = 57641
View Source
const REFERENCES = 57642
View Source
const REFRESH = 57643
View Source
const REINDEX = 57644
View Source
const RELATIVE = 57645
View Source
const RELEASE = 57646
View Source
const RENAME = 57647
View Source
const REPEATABLE = 57648
View Source
const REPLACE = 57649
View Source
const REPLICA = 57650
View Source
const RESET = 57651
View Source
const RESTART = 57652
View Source
const RESTRICT = 57653
View Source
const RETURNING = 57654
View Source
const RETURNS = 57655
View Source
const REVOKE = 57656
View Source
const RIGHT = 57657
View Source
const ROLLBACK = 57658
View Source
const ROLLUP = 57659
View Source
const ROW = 57660
View Source
const ROWS = 57661
View Source
const RULE = 57662
View Source
const SAVEPOINT = 57663
View Source
const SCONST = 57348
View Source
const SCROLL = 57664
View Source
const SEARCH = 57665
View Source
const SECOND = 57666
View Source
const SECURITY = 57667
View Source
const SELECT = 57668
View Source
const SEQUENCE = 57669
View Source
const SEQUENCES = 57670
View Source
const SERIALIZABLE = 57671
View Source
const SERVER = 57672
View Source
const SESSION = 57673
View Source
const SESSION_USER = 57674
View Source
const SET = 57675
View Source
const SETOF = 57677
View Source
const SETS = 57676
View Source
const SHARE = 57678
View Source
const SHOW = 57679
View Source
const SIMILAR = 57680
View Source
const SIMPLE = 57681
View Source
const SKIP = 57682
View Source
const SMALLINT = 57683
View Source
const SNAPSHOT = 57684
View Source
const SOME = 57685
View Source
const SQL = 57686
View Source
const STABLE = 57687
View Source
const STANDALONE = 57688
View Source
const START = 57689
View Source
const STATEMENT = 57690
View Source
const STATISTICS = 57691
View Source
const STDIN = 57692
View Source
const STDOUT = 57693
View Source
const STRICT = 57694
View Source
const STRIP = 57695
View Source
const SUBSTRING = 57696
View Source
const SYMMETRIC = 57697
View Source
const SYSID = 57698
View Source
const SYSTEM = 57699
View Source
const TABLE = 57700
View Source
const TABLES = 57701
View Source
const TEXT = 57702
View Source
const THEN = 57703
View Source
const TIME = 57704
View Source
const TIMESTAMP = 57705
View Source
const TO = 57706
View Source
const TRAILING = 57707
View Source
const TRANSACTION = 57708
View Source
const TRANSFORM = 57709
View Source
const TREAT = 57710
View Source
const TRIGGER = 57711
View Source
const TRIM = 57712
View Source
const TRUE = 57713
View Source
const TRUNCATE = 57714
View Source
const TRUSTED = 57715
View Source
const TYPE = 57716
View Source
const TYPECAST = 57353
View Source
const TYPES = 57717
View Source
const UMINUS = 57756
View Source
const UNBOUNDED = 57718
View Source
const UNCOMMITTED = 57719
View Source
const UNENCRYPTED = 57720
View Source
const UNION = 57721
View Source
const UNIQUE = 57722
View Source
const UNKNOWN = 57723
View Source
const UNLISTEN = 57724
View Source
const UNLOGGED = 57725
View Source
const UNTIL = 57726
View Source
const UPDATE = 57727
View Source
const USER = 57728
View Source
const USING = 57729
View Source
const VACUUM = 57730
View Source
const VALID = 57731
View Source
const VALIDATE = 57732
View Source
const VALUE = 57733
View Source
const VALUES = 57734
View Source
const VARCHAR = 57735
View Source
const VARIADIC = 57736
View Source
const VARYING = 57737
View Source
const VERBOSE = 57738
View Source
const VERSION = 57739
View Source
const WHEN = 57740
View Source
const WHERE = 57741
View Source
const WINDOW = 57742
View Source
const WITH = 57743
View Source
const WITHIN = 57744
View Source
const WITHOUT = 57745
View Source
const WITH_LA = 57754
View Source
const WORK = 57746
View Source
const WRAPPER = 57747
View Source
const WRITE = 57748
View Source
const XCONST = 57350
View Source
const YEAR = 57749
View Source
const YES = 57750
View Source
const ZONE = 57751

Variables

View Source
var DNull = dNull{}

DNull is the NULL Datum.

View Source
var StarExpr = &QualifiedName{Indirect: Indirection{unqualifiedStar}}

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

View Source
var StarSelectExpr = SelectExpr{Expr: StarExpr}

StarSelectExpr is a convenience variable that represents an unqualified "*" in a select expression.

Functions

func FillArgs

func FillArgs(stmt Statement, args Args) error

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

func WalkStmt

func WalkStmt(v Visitor, stmt Statement)

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

Types

type AliasedTableExpr

type AliasedTableExpr struct {
	Expr SimpleTableExpr
	As   Name
}

AliasedTableExpr represents a table expression coupled with an optional alias.

func (*AliasedTableExpr) String

func (node *AliasedTableExpr) String() string

type AndExpr

type AndExpr struct {
	Left, Right Expr
}

AndExpr represents an AND expression.

func (*AndExpr) String

func (node *AndExpr) String() string

type Args

type Args interface {
	Arg(i int) (Datum, bool)
}

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

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 BinaryExpr

type BinaryExpr struct {
	Operator    BinaryOp
	Left, Right Expr
}

BinaryExpr represents a binary value expression.

func (*BinaryExpr) String

func (node *BinaryExpr) String() string

type BinaryOp

type BinaryOp int

BinaryOp represents a binary operator.

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

BinaryExpr.Operator

func (BinaryOp) String

func (i BinaryOp) String() string

type BitType

type BitType struct {
	N int
}

BitType represents a BIT type.

func (*BitType) String

func (node *BitType) String() string

type BlobType

type BlobType struct {
	Name string
}

BlobType represents a BLOB type.

func (*BlobType) String

func (node *BlobType) String() string

type BoolType

type BoolType struct{}

BoolType represents a BOOLEAN type.

func (*BoolType) String

func (node *BoolType) String() string

type BoolVal

type BoolVal bool

BoolVal represents a boolean.

func (BoolVal) String

func (node BoolVal) String() string

type BytesVal

type BytesVal string

BytesVal represents a string of unprintable value.

func (BytesVal) String

func (node BytesVal) String() string

type CaseExpr

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

CaseExpr represents a CASE expression.

func (*CaseExpr) String

func (node *CaseExpr) String() string

type CastExpr

type CastExpr struct {
	Expr Expr
	Type ColumnType
}

CastExpr represents a CAST(expr AS type) expression.

func (*CastExpr) String

func (n *CastExpr) String() string

type CharType

type CharType struct {
	Name string
	N    int
}

CharType represents a CHAR or VARCHAR type.

func (*CharType) String

func (node *CharType) String() string

type ColumnConstraint

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

ColumnConstraint represents a constraint on a column.

type ColumnTableDef

type ColumnTableDef struct {
	Name       Name
	Type       ColumnType
	Nullable   Nullability
	PrimaryKey bool
	Unique     bool
}

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 ComparisonExpr

type ComparisonExpr struct {
	Operator    ComparisonOp
	Left, Right Expr
}

ComparisonExpr represents a two-value comparison expression.

func (*ComparisonExpr) String

func (node *ComparisonExpr) String() string

type ComparisonOp

type ComparisonOp int

ComparisonOp represents a binary operator.

const (
	EQ ComparisonOp = iota
	LT
	GT
	LE
	GE
	NE
	In
	NotIn
	Like
	NotLike
)

ComparisonExpr.Operator

func (ComparisonOp) String

func (i ComparisonOp) String() string

type CreateDatabase

type CreateDatabase struct {
	IfNotExists bool
	Name        Name
}

CreateDatabase represents a CREATE DATABASE statement.

func (*CreateDatabase) String

func (node *CreateDatabase) String() string

type CreateTable

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

CreateTable represents a CREATE TABLE statement.

func (*CreateTable) String

func (node *CreateTable) String() string

type DBool

type DBool bool

DBool is the boolean Datum.

func (DBool) String

func (d DBool) String() string

func (DBool) Type

func (d DBool) Type() string

Type implements the Datum interface.

type DFloat

type DFloat float64

DFloat is the float Datum.

func (DFloat) String

func (d DFloat) String() string

func (DFloat) Type

func (d DFloat) Type() string

Type implements the Datum interface.

type DInt

type DInt int64

DInt is the int Datum.

func (DInt) String

func (d DInt) String() string

func (DInt) Type

func (d DInt) Type() string

Type implements the Datum interface.

type DString

type DString string

DString is the string Datum.

func (DString) String

func (d DString) String() string

func (DString) Type

func (d DString) Type() string

Type implements the Datum interface.

type DTuple

type DTuple []Datum

DTuple is the tuple Datum.

func (DTuple) String

func (d DTuple) String() string

func (DTuple) Type

func (d DTuple) Type() string

Type implements the Datum 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() string
}

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

func EvalExpr

func EvalExpr(expr Expr) (Datum, error)

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

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 Delete

type Delete struct {
	Table TableExpr
	Where *Where
}

Delete represents a DELETE statement.

func (*Delete) String

func (node *Delete) String() string

type DropDatabase

type DropDatabase struct {
	Name     Name
	IfExists bool
}

DropDatabase represents a DROP DATABASE statement.

func (*DropDatabase) String

func (node *DropDatabase) String() string

type DropTable

type DropTable struct {
	Names    QualifiedNames
	IfExists bool
}

DropTable represents a DROP TABLE statement.

func (*DropTable) String

func (node *DropTable) String() string

type ExistsExpr

type ExistsExpr struct {
	Subquery *Subquery
}

ExistsExpr represents an EXISTS expression.

func (*ExistsExpr) String

func (node *ExistsExpr) String() string

type Explain

type Explain struct {
	Options   []string
	Statement Statement
}

Explain represents an EXPLAIN statement.

func (*Explain) String

func (node *Explain) String() string

type Expr

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

Expr represents an expression.

func WalkExpr

func WalkExpr(v Visitor, expr Expr) Expr

WalkExpr traverses the nodes in an expression. It starts by calling v.Visit(expr). It then recursively traverses the children nodes of the expression returned by v.Visit().

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
	Distinct bool
	Exprs    Exprs
}

FuncExpr represents a function call.

func (*FuncExpr) String

func (node *FuncExpr) String() string

type Grant

type Grant struct {
	Privileges PrivilegeList
	Targets    TargetList
	Grantees   NameList
}

Grant represents a GRANT statement.

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 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
	PrimaryKey bool
	Unique     bool
	Columns    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    SelectStatement
}

Insert represents an INSERT statement.

func (*Insert) String

func (node *Insert) String() string

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 int64

IntVal represents an integer.

func (IntVal) String

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

func (node *NotExpr) String() string

type NotNullConstraint

type NotNullConstraint struct{}

NotNullConstraint represents NOT NULL on a column.

type NullCheck

type NullCheck struct {
	Not  bool
	Expr Expr
}

NullCheck represents an IS NULL or an IS NOT NULL expression.

func (*NullCheck) String

func (node *NullCheck) String() string

type NullConstraint

type NullConstraint struct{}

NullConstraint represents NULL on a column.

type NullVal

type NullVal struct{}

NullVal represents a NULL value.

func (NullVal) String

func (NullVal) String() string

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

func (node NumVal) String() string

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

func (node *OrExpr) String() string

type Order

type Order struct {
	Expr      Expr
	Direction string
}

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 ParenExpr

type ParenExpr struct {
	Expr Expr
}

ParenExpr represents a parenthesized expression.

func (*ParenExpr) String

func (node *ParenExpr) String() string

type ParenSelect

type ParenSelect struct {
	Select SelectStatement
}

ParenSelect represents a parenthesized SELECT/UNION/VALUES statement.

func (*ParenSelect) String

func (node *ParenSelect) String() string

type ParenTableExpr

type ParenTableExpr struct {
	Expr TableExpr
}

ParenTableExpr represents a parenthesized TableExpr.

func (*ParenTableExpr) String

func (node *ParenTableExpr) String() string

type PrimaryKeyConstraint

type PrimaryKeyConstraint struct{}

PrimaryKeyConstraint represents NULL on a column.

type PrivilegeList

type PrivilegeList []PrivilegeType

PrivilegeList represents a list of privileges.

func (PrivilegeList) Join

func (pl PrivilegeList) Join(sep string) string

Join returns the list of privilege names joined using `sep`. The default stringer uses `, `, but we want to be able to get a tight representation of the string.

func (PrivilegeList) String

func (pl PrivilegeList) String() string

type PrivilegeType

type PrivilegeType int

PrivilegeType represents the type of privilege.

func (PrivilegeType) String

func (pt PrivilegeType) String() string

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

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

func (node *RangeCond) String() string

type RenameDatabase

type RenameDatabase struct {
	Name    Name
	NewName Name
}

RenameDatabase represents a RENAME DATABASE statement.

func (*RenameDatabase) String

func (node *RenameDatabase) String() string

type RenameTable

type RenameTable struct {
	Name    Name
	NewName Name
}

RenameTable represents a RENAME TABLE statement.

func (*RenameTable) String

func (node *RenameTable) String() string

type Revoke

type Revoke struct {
	Privileges PrivilegeList
	Targets    TargetList
	Grantees   NameList
}

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

func (*Revoke) String

func (node *Revoke) String() string

type Row

type Row Exprs

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

func (Row) String

func (node Row) String() string

type Select

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

Select represents a SELECT statement.

func (*Select) String

func (node *Select) String() string

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

func (node *Set) String() string

type ShowColumns

type ShowColumns struct {
	Table *QualifiedName
}

ShowColumns represents a SHOW COLUMNS statement.

func (*ShowColumns) String

func (node *ShowColumns) String() string

type ShowDatabases

type ShowDatabases struct {
}

ShowDatabases represents a SHOW DATABASES statement.

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

func (node *ShowGrants) String() string

type ShowIndex

type ShowIndex struct {
	Table *QualifiedName
}

ShowIndex represents a SHOW INDEX statement.

func (*ShowIndex) String

func (node *ShowIndex) String() string

type ShowTables

type ShowTables struct {
	Name *QualifiedName
}

ShowTables represents a SHOW TABLES statement.

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

Statement represents a statement.

type StatementList

type StatementList []Statement

StatementList is a list of statements.

func Parse

func Parse(sql string) (StatementList, error)

Parse parses the sql and returns a list of statements.

func (StatementList) String

func (l StatementList) String() string

type StrVal

type StrVal string

StrVal represents a string value.

func (StrVal) String

func (node StrVal) String() string

type Subquery

type Subquery struct {
	Select SelectStatement
}

Subquery represents a subquery.

func (*Subquery) String

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

func (TargetType) String

func (tt TargetType) String() string

type TextType

type TextType struct {
	Name string
}

TextType represents a TEXT type.

func (*TextType) String

func (node *TextType) String() string

type TimeType

type TimeType struct {
}

TimeType represents a TIME type.

func (*TimeType) String

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

func (node *Truncate) String() string

type Tuple

type Tuple Exprs

Tuple represents a parenthesized list of expressions.

func (Tuple) String

func (node Tuple) String() string

type UnaryExpr

type UnaryExpr struct {
	Operator UnaryOp
	Expr     Expr
}

UnaryExpr represents a unary value expression.

func (*UnaryExpr) String

func (node *UnaryExpr) String() string

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 Union

type Union struct {
	Type        string
	Left, Right SelectStatement
}

Union represents a UNION statement.

func (*Union) String

func (node *Union) String() string

type UniqueConstraint

type UniqueConstraint struct{}

UniqueConstraint represents UNIQUE on a column.

type Update

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

Update represents an UPDATE statement.

func (*Update) String

func (node *Update) String() string

type UpdateExpr

type UpdateExpr struct {
	Name *QualifiedName
	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 UsingJoinCond

type UsingJoinCond struct {
	Cols NameList
}

UsingJoinCond represents a USING join condition.

func (*UsingJoinCond) String

func (node *UsingJoinCond) String() string

type ValArg

type ValArg int

ValArg represents a named bind var argument.

func (ValArg) String

func (node ValArg) String() string

type Values

type Values []Tuple

Values represents a VALUES clause.

func (Values) String

func (node Values) String() string

type Visitor

type Visitor interface {
	Visit(expr Expr) Expr
}

The Visitor Visit method is invoked for each Expr node encountered by WalkExpr. The returned Expr replaces the pointer to the visited expression in the parent node and can be used for rewriting expressions.

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