sqlparser

package
v0.0.0-...-a142604 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2017 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AST_JOIN          = "join"
	AST_STRAIGHT_JOIN = "straight_join"
	AST_LEFT_JOIN     = "left join"
	AST_RIGHT_JOIN    = "right join"
	AST_CROSS_JOIN    = "cross join"
	AST_NATURAL_JOIN  = "natural join"
)

JoinTableExpr.Join

View Source
const (
	AST_USE    = "use"
	AST_IGNORE = "ignore"
	AST_FORCE  = "force"
)
View Source
const (
	AST_WHERE  = "where"
	AST_HAVING = "having"
)

Where.Type

View Source
const (
	AST_EQ       = "="
	AST_LT       = "<"
	AST_GT       = ">"
	AST_LE       = "<="
	AST_GE       = ">="
	AST_NE       = "!="
	AST_NSE      = "<=>"
	AST_IN       = "in"
	AST_NOT_IN   = "not in"
	AST_LIKE     = "like"
	AST_NOT_LIKE = "not like"
)

ComparisonExpr.Operator

View Source
const (
	AST_BETWEEN     = "between"
	AST_NOT_BETWEEN = "not between"
)

RangeCond.Operator

View Source
const (
	AST_IS_NULL     = "is null"
	AST_IS_NOT_NULL = "is not null"
)

NullCheck.Operator

View Source
const (
	AST_BITAND = '&'
	AST_BITOR  = '|'
	AST_BITXOR = '^'
	AST_PLUS   = '+'
	AST_MINUS  = '-'
	AST_MULT   = '*'
	AST_DIV    = '/'
	AST_MOD    = '%'
)

BinaryExpr.Operator

View Source
const (
	AST_UPLUS  = '+'
	AST_UMINUS = '-'
	AST_TILDA  = '~'
)

UnaryExpr.Operator

View Source
const (
	AST_ASC  = "asc"
	AST_DESC = "desc"
)

Order.Direction

View Source
const (
	AST_FOR_UPDATE = " for update"
	AST_SHARE_MODE = " lock in share mode"
)

Select.Lock

View Source
const (
	AST_UNION     = "union"
	AST_UNION_ALL = "union all"
	AST_SET_MINUS = "minus"
	AST_EXCEPT    = "except"
	AST_INTERSECT = "intersect"
)

Union.Type

View Source
const ACTION = 57644
View Source
const ADD = 57651
View Source
const AFTER = 57650
View Source
const ALL = 57359
View Source
const ALTER = 57582
View Source
const AND = 57398
View Source
const ARMSCII8 = 57430
View Source
const ARMSCII8_BIN = 57471
View Source
const ARMSCII8_GENERAL_CI = 57470
View Source
const AS = 57361
View Source
const ASC = 57364
View Source
const ASCII = 57431
View Source
const ASCII_BIN = 57473
View Source
const ASCII_GENERAL_CI = 57472
View Source
const (
	AST_DISTINCT = "distinct "
)

Select.Distinct

View Source
const AUTO_INCREMENT = 57628
View Source
const BEGIN = 57414
View Source
const BETWEEN = 57400
View Source
const BIG5 = 57432
View Source
const BIG5_BIN = 57475
View Source
const BIG5_CHINESE_CI = 57474
View Source
const BIGINT = 57604
View Source
const BINARY = 57433
View Source
const BIT = 57596
View Source
const BLOB = 57624
View Source
const BOOL = 57598
View Source
const BOOLEAN = 57599
View Source
const BTREE = 57594
View Source
const BY = 57356
View Source
const CASCADE = 57642
View Source
const CASE = 57401
View Source
const CHANGE = 57653
View Source
const CHAR = 57614
View Source
const CHARACTER = 57428
View Source
const CHARSET = 57427
View Source
const COLLATE = 57580
View Source
const COLLATION = 57429
View Source
const COLUMN = 57652
View Source
const COLUMNS = 57566
View Source
const COLUMN_FORMAT = 57633
View Source
const COMMENT = 57632
View Source
const COMMENTS = 57380
View Source
const COMMIT = 57417
View Source
const COMMITTED = 57422
View Source
const CONNECTION = 57659
View Source
const CONSTRAINT = 57647
View Source
const CP1250 = 57434
View Source
const CP1250_BIN = 57477
View Source
const CP1250_GENERAL_CI = 57476
View Source
const CP1251 = 57435
View Source
const CP1251_BIN = 57480
View Source
const CP1251_GENERAL_CI = 57478
View Source
const CP1251_GENERAL_CS = 57479
View Source
const CP1256 = 57436
View Source
const CP1256_BIN = 57482
View Source
const CP1256_GENERAL_CI = 57481
View Source
const CP1257 = 57437
View Source
const CP1257_BIN = 57484
View Source
const CP1257_GENERAL_CI = 57483
View Source
const CP850 = 57438
View Source
const CP850_BIN = 57486
View Source
const CP850_GENERAL_CI = 57485
View Source
const CP852 = 57439
View Source
const CP852_BIN = 57488
View Source
const CP852_GENERAL_CI = 57487
View Source
const CP866 = 57440
View Source
const CP866_BIN = 57490
View Source
const CP866_GENERAL_CI = 57489
View Source
const CP932 = 57441
View Source
const CP932_BIN = 57492
View Source
const CP932_JAPANESE_CI = 57491
View Source
const CREATE = 57581
View Source
const CROSS = 57392
View Source
const DATABASE = 57562
View Source
const DATABASES = 57560
View Source
const DATE = 57609
View Source
const DATETIME = 57612
View Source
const DEC8 = 57442
View Source
const DEC8_BIN = 57494
View Source
const DEC8_SWEDISH_CI = 57493
View Source
const DECIMAL = 57608
View Source
const DEFAULT = 57370
View Source
const DELETE = 57350
View Source
const DESC = 57365
View Source
const DESCRIBE = 57375
View Source
const DISABLE = 57656
View Source
const DISK = 57636
View Source
const DISTINCT = 57360
View Source
const DOUBLE = 57606
View Source
const DROP = 57583
View Source
const DUPLICATE = 57368
View Source
const DYNAMIC = 57635
View Source
const ELSE = 57404
View Source
const ENABLE = 57655
View Source
const END = 57413
View Source
const ENGINE = 57629
View Source
const ENGINES = 57564
View Source
const ENUM = 57627
View Source
const EOFCHAR = 0x100

EOFCHAR EOF char.

View Source
const EUCJPMS = 57443
View Source
const EUCJPMS_BIN = 57496
View Source
const EUCJPMS_JAPANESE_CI = 57495
View Source
const EUCKR = 57444
View Source
const EUCKR_BIN = 57498
View Source
const EUCKR_KOREAN_CI = 57497
View Source
const EXCEPT = 57383
View Source
const EXISTS = 57362
View Source
const EXPLAIN = 57374
View Source
const FIELDS = 57567
View Source
const FIRST = 57649
View Source
const FIXED = 57634
View Source
const FLOAT = 57607
View Source
const FOR = 57358
View Source
const FORCE = 57395
View Source
const FOREIGN = 57648
View Source
const FROM = 57351
View Source
const FULL = 57385
View Source
const FULLTEXT = 57592
View Source
const FUNCTION = 57569
View Source
const GB2312 = 57445
View Source
const GB2312_BIN = 57500
View Source
const GB2312_CHINESE_CI = 57499
View Source
const GBK = 57446
View Source
const GBK_BIN = 57502
View Source
const GBK_CHINESE_CI = 57501
View Source
const GE = 57406
View Source
const GEOSTD8 = 57447
View Source
const GEOSTD8_BIN = 57504
View Source
const GEOSTD8_GENERAL_CI = 57503
View Source
const GLOBAL = 57557
View Source
const GREEK = 57448
View Source
const GREEK_BIN = 57506
View Source
const GREEK_GENERAL_CI = 57505
View Source
const GROUP = 57353
View Source
const HASH = 57595
View Source
const HAVING = 57354
View Source
const HEBREW = 57449
View Source
const HEBREW_BIN = 57508
View Source
const HEBREW_GENERAL_CI = 57507
View Source
const HP8 = 57450
View Source
const HP8_BIN = 57510
View Source
const HP8_ENGLISH_CI = 57509
View Source
const ID = 57376
View Source
const IF = 57590
View Source
const IGNORE = 57589
View Source
const IN = 57411
View Source
const INDEX = 57586
View Source
const INDEXES = 57570
View Source
const INNER = 57390
View Source
const INSERT = 57348
View Source
const INT = 57602
View Source
const INTEGER = 57603
View Source
const INTERSECT = 57384
View Source
const INTO = 57367
View Source
const IS = 57409
View Source
const ISOLATION = 57419
View Source
const JOIN = 57386
View Source
const KEY = 57369
View Source
const KEYBCS2 = 57451
View Source
const KEYBCS2_BIN = 57512
View Source
const KEYBCS2_GENERAL_CI = 57511
View Source
const KEYS = 57571
View Source
const KILL = 57657
View Source
const KOI8R = 57452
View Source
const KOI8R_BIN = 57514
View Source
const KOI8R_GENERAL_CI = 57513
View Source
const KOI8U = 57453
View Source
const KOI8U_BIN = 57516
View Source
const KOI8U_GENERAL_CI = 57515
View Source
const LATIN1 = 57454
View Source
const LATIN1_BIN = 57519
View Source
const LATIN1_GENERAL_CI = 57517
View Source
const LATIN1_GENERAL_CS = 57518
View Source
const LATIN2 = 57455
View Source
const LATIN2_BIN = 57521
View Source
const LATIN2_GENERAL_CI = 57520
View Source
const LATIN5 = 57456
View Source
const LATIN5_BIN = 57523
View Source
const LATIN5_TURKISH_CI = 57522
View Source
const LATIN7 = 57457
View Source
const LATIN7_BIN = 57526
View Source
const LATIN7_GENERAL_CI = 57524
View Source
const LATIN7_GENERAL_CS = 57525
View Source
const LE = 57405
View Source
const LEFT = 57388
View Source
const LEVEL = 57420
View Source
const LEX_ERROR = 57346
View Source
const LIKE = 57410
View Source
const LIMIT = 57357
View Source
const LOCK = 57372
View Source
const LONGBLOB = 57626
View Source
const LONGTEXT = 57621
View Source
const MACCE = 57458
View Source
const MACCE_BIN = 57528
View Source
const MACCE_GENERAL_CI = 57527
View Source
const MACROMAN = 57459
View Source
const MACROMAN_BIN = 57530
View Source
const MACROMAN_GENERAL_CI = 57529
View Source
const MATCH = 57638
View Source
const MEDIUMBLOB = 57625
View Source
const MEDIUMINT = 57601
View Source
const MEDIUMTEXT = 57620
View Source
const MEMORY = 57637
View Source
const MINUS = 57382
View Source
const MODIFY = 57654
View Source
const NAMES = 57426
View Source
const NATURAL = 57393
View Source
const NCHAR = 57615
View Source
const NE = 57407
View Source
const NO = 57643
View Source
const NOT = 57399
View Source
const NULL = 57363
View Source
const NULL_SAFE_EQUAL = 57408
View Source
const NUMBER = 57378
View Source
const NVARCHAR = 57617
View Source
const OFFSET = 57579
View Source
const ON = 57396
View Source
const OR = 57397
View Source
const ORDER = 57355
View Source
const OUTER = 57391
View Source
const PARTIAL = 57639
View Source
const PLUGINS = 57574
View Source
const POSITION = 57660
View Source
const PRIMARY = 57630
View Source
const PROCEDURE = 57568
View Source
const PROCESSLIST = 57575
View Source
const PROFILES = 57577
View Source
const QUERY = 57658
View Source
const READ = 57421
View Source
const REAL = 57605
View Source
const REFERENCES = 57631
View Source
const RENAME = 57584
View Source
const REPEATABLE = 57424
View Source
const REPLACE = 57578
View Source
const RESTRICT = 57641
View Source
const RIGHT = 57389
View Source
const ROLLBACK = 57418
View Source
const SCHEMAS = 57561
View Source
const SELECT = 57347
View Source
const SERIALIZABLE = 57425
View Source
const SESSION = 57556
View Source
const SET = 57371
View Source
const SHOW = 57373
View Source
const SIMPLE = 57640
View Source
const SJIS = 57460
View Source
const SJIS_BIN = 57532
View Source
const SJIS_JAPANESE_CI = 57531
View Source
const SLAVE = 57576
View Source
const SMALLINT = 57600
View Source
const START = 57415
View Source
const STATUS = 57559
View Source
const STORAGE = 57563
View Source
const STRAIGHT_JOIN = 57387
View Source
const STRING = 57377
View Source
const SWE7 = 57461
View Source
const SWE7_BIN = 57534
View Source
const SWE7_SWEDISH_CI = 57533
View Source
const TABLE = 57585
View Source
const TABLES = 57565
View Source
const TEXT = 57619
View Source
const THEN = 57403
View Source
const TIME = 57610
View Source
const TIMESTAMP = 57611
View Source
const TINYBLOB = 57623
View Source
const TINYINT = 57597
View Source
const TINYTEXT = 57618
View Source
const TIS620 = 57462
View Source
const TIS620_BIN = 57536
View Source
const TIS620_THAI_CI = 57535
View Source
const TO = 57588
View Source
const TRANSACTION = 57416
View Source
const TRIGGER = 57572
View Source
const TRIGGERS = 57573
View Source
const UCS2 = 57463
View Source
const UCS2_BIN = 57539
View Source
const UCS2_GENERAL_CI = 57537
View Source
const UCS2_UNICODE_CI = 57538
View Source
const UJIS = 57464
View Source
const UJIS_BIN = 57541
View Source
const UJIS_JAPANESE_CI = 57540
View Source
const UNARY = 57412
View Source
const UNCOMMITTED = 57423
View Source
const UNION = 57381
View Source
const UNIQUE = 57591
View Source
const UNSIGNED = 57645
View Source
const UPDATE = 57349
View Source
const USE = 57394
View Source
const USING = 57593
View Source
const UTF16 = 57465
View Source
const UTF16LE = 57466
View Source
const UTF16LE_BIN = 57546
View Source
const UTF16LE_GENERAL_CI = 57545
View Source
const UTF16_BIN = 57544
View Source
const UTF16_GENERAL_CI = 57542
View Source
const UTF16_UNICODE_CI = 57543
View Source
const UTF32 = 57467
View Source
const UTF32_BIN = 57549
View Source
const UTF32_GENERAL_CI = 57547
View Source
const UTF32_UNICODE_CI = 57548
View Source
const UTF8 = 57468
View Source
const UTF8MB4 = 57469
View Source
const UTF8MB4_BIN = 57555
View Source
const UTF8MB4_GENERAL_CI = 57553
View Source
const UTF8MB4_UNICODE_CI = 57554
View Source
const UTF8_BIN = 57552
View Source
const UTF8_GENERAL_CI = 57550
View Source
const UTF8_UNICODE_CI = 57551
View Source
const VALUES = 57366
View Source
const VALUE_ARG = 57379
View Source
const VARBINARY = 57622
View Source
const VARCHAR = 57616
View Source
const VARIABLES = 57558
View Source
const VIEW = 57587
View Source
const WHEN = 57402
View Source
const WHERE = 57352
View Source
const YEAR = 57613
View Source
const ZEROFILL = 57646

Variables

View Source
var (
	SHARE        = []byte("share")
	MODE         = []byte("mode")
	IF_BYTES     = []byte("if")
	VALUES_BYTES = []byte("values")
)

Functions

func CheckTableExprs

func CheckTableExprs(tabExprs TableExprs, tableNames interface{}) (err error)

CheckTableExprs remove db and check table's name.

func CheckTableExprsInSelect

func CheckTableExprsInSelect(stmt SelectStatement, tableNames interface{}) (err error)

CheckTableExprsInSelect remove db and check table's name.

func ForceEOF

func ForceEOF(yylex interface{})

ForceEOF force EOF.

func GetColName

func GetColName(node Expr) string

GetColName returns the column name, only if it's a simple expression. Otherwise, it returns "".

func IsOnlySystemDBInTableExprs

func IsOnlySystemDBInTableExprs(tabExprs TableExprs) bool

IsOnlySystemDBInTableExprs only system db in table exprs.

func IsSystemDB

func IsSystemDB(db string) bool

IsSystemDB is system db or not.

func SetAllowComments

func SetAllowComments(yylex interface{}, allow bool)

SetAllowComments set allow comments.

func SetLimitInSelect

func SetLimitInSelect(statement SelectStatement, maxRowCount int)

SetLimitInSelect set limit expression in select statement.

func SetParseTree

func SetParseTree(yylex interface{}, stmt Statement)

SetParseTree to build ast.

func SplitSQLStatement

func SplitSQLStatement(multiSQL string) []string

SplitSQLStatement is to split multi-sql to single-sql.

func String

func String(node SQLNode) string

String returns a string representation of an SQLNode.

Types

type AddForeignKeySpec

type AddForeignKeySpec struct {
	Symbol       []byte
	IndexColumns IndexColNames
	ReferenceDef []byte
}

AddForeignKeySpec add foreign key specification

func (*AddForeignKeySpec) Format

func (node *AddForeignKeySpec) Format(buf *TrackedBuffer)

Format AddForeignKeySpec

func (*AddForeignKeySpec) IAlterSpecification

func (node *AddForeignKeySpec) IAlterSpecification()

type AddIndexSpec

type AddIndexSpec struct {
	Name         []byte
	IndexType    []byte
	IndexColumns IndexColNames
}

AddIndexSpec add index specification

func (*AddIndexSpec) Format

func (node *AddIndexSpec) Format(buf *TrackedBuffer)

Format AddIndexSpec

func (*AddIndexSpec) IAlterSpecification

func (node *AddIndexSpec) IAlterSpecification()

type AddOrModifyColumnSpec

type AddOrModifyColumnSpec struct {
	Action             string
	ColumnName         *ColName
	ColumnDef          *ColumnDefinition
	FirstOrAfterColumn *FirstOrAfterColumn
}

AddOrModifyColumnSpec add column specification

func (*AddOrModifyColumnSpec) Format

func (node *AddOrModifyColumnSpec) Format(buf *TrackedBuffer)

Format AddOrModifyColumnSpec

func (*AddOrModifyColumnSpec) IAlterSpecification

func (node *AddOrModifyColumnSpec) IAlterSpecification()

type AddPrimaryKeySpec

type AddPrimaryKeySpec struct {
	Symbol       []byte
	IndexType    []byte
	IndexColumns IndexColNames
}

AddPrimaryKeySpec add primary key specification

func (*AddPrimaryKeySpec) Format

func (node *AddPrimaryKeySpec) Format(buf *TrackedBuffer)

Format AddPrimaryKeySpec

func (*AddPrimaryKeySpec) IAlterSpecification

func (node *AddPrimaryKeySpec) IAlterSpecification()

type AddUniqueIndexSpec

type AddUniqueIndexSpec struct {
	Symbol       []byte
	Name         []byte
	IndexType    []byte
	IndexColumns IndexColNames
}

AddUniqueIndexSpec add unique index specification

func (*AddUniqueIndexSpec) Format

func (node *AddUniqueIndexSpec) Format(buf *TrackedBuffer)

Format AddUniqueIndexSpec

func (*AddUniqueIndexSpec) IAlterSpecification

func (node *AddUniqueIndexSpec) IAlterSpecification()

type AdminStatement

type AdminStatement interface {
	IStatement()
	IAdminStatement()
	SQLNode
}

AdminStatement admin statement.

type AliasedTableExpr

type AliasedTableExpr struct {
	Expr  SimpleTableExpr
	As    []byte
	Hints *IndexHints
}

AliasedTableExpr represents a table expression coupled with an optional alias or index hint.

func (*AliasedTableExpr) Format

func (node *AliasedTableExpr) Format(buf *TrackedBuffer)

func (*AliasedTableExpr) ITableExpr

func (*AliasedTableExpr) ITableExpr()

type AlterSpecification

type AlterSpecification interface {
	IAlterSpecification()
	SQLNode
}

AlterSpecification alter specification

type AlterSpecifications

type AlterSpecifications []AlterSpecification

AlterSpecifications alter specification list

func (AlterSpecifications) Format

func (node AlterSpecifications) Format(buf *TrackedBuffer)

Format AlterSpecifications

type AlterTable

type AlterTable struct {
	Comments   Comments
	Ignore     string
	Table      *TableName
	AlterSpecs AlterSpecifications
}

AlterTable alter table

func (*AlterTable) Format

func (node *AlterTable) Format(buf *TrackedBuffer)

Format AlterTable

func (*AlterTable) IDDLStatement

func (node *AlterTable) IDDLStatement()

func (*AlterTable) IStatement

func (node *AlterTable) IStatement()

type AndExpr

type AndExpr struct {
	Left, Right BoolExpr
}

AndExpr represents an AND expression.

func (*AndExpr) Format

func (node *AndExpr) Format(buf *TrackedBuffer)

func (*AndExpr) IBoolExpr

func (*AndExpr) IBoolExpr()

func (*AndExpr) IExpr

func (*AndExpr) IExpr()

type Begin

type Begin struct {
}

Begin statement

func (*Begin) Format

func (node *Begin) Format(buf *TrackedBuffer)

func (*Begin) IStatement

func (node *Begin) IStatement()

func (*Begin) ITransactionStatement

func (node *Begin) ITransactionStatement()

type BinaryExpr

type BinaryExpr struct {
	Operator    byte
	Left, Right Expr
}

BinaryExpr represents a binary value expression.

func (*BinaryExpr) Format

func (node *BinaryExpr) Format(buf *TrackedBuffer)

func (*BinaryExpr) IExpr

func (*BinaryExpr) IExpr()

func (*BinaryExpr) IValExpr

func (*BinaryExpr) IValExpr()

type BoolExpr

type BoolExpr interface {
	IBoolExpr()
	Expr
}

BoolExpr represents a boolean expression.

type CaseExpr

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

CaseExpr represents a CASE expression.

func (*CaseExpr) Format

func (node *CaseExpr) Format(buf *TrackedBuffer)

func (*CaseExpr) IExpr

func (*CaseExpr) IExpr()

func (*CaseExpr) IValExpr

func (*CaseExpr) IValExpr()

type ChangeColumnSpec

type ChangeColumnSpec struct {
	OldColumnName      *ColName
	ColumnName         *ColName
	ColumnDef          *ColumnDefinition
	FirstOrAfterColumn *FirstOrAfterColumn
}

ChangeColumnSpec add column specification

func (*ChangeColumnSpec) Format

func (node *ChangeColumnSpec) Format(buf *TrackedBuffer)

Format ChangeColumnSpec

func (*ChangeColumnSpec) IAlterSpecification

func (node *ChangeColumnSpec) IAlterSpecification()

type ColName

type ColName struct {
	Name, Qualifier []byte
}

ColName represents a column name.

func (*ColName) Format

func (node *ColName) Format(buf *TrackedBuffer)

func (*ColName) IExpr

func (*ColName) IExpr()

func (*ColName) IValExpr

func (*ColName) IValExpr()

type ColNames

type ColNames []*ColName

ColNames ColName list

func (ColNames) Format

func (node ColNames) Format(buf *TrackedBuffer)

Format ColNames

type ColumnDefinition

type ColumnDefinition struct {
	Type            *DataType
	IsNotNull       bool
	DefaultValue    ValExpr
	IsAutoIncrement bool
	UniqueOrKey     []byte
	ColumnComment   ValExpr
	ColumnFormat    []byte
	ColumnStorage   []byte
	ReferenceDef    []byte
}

ColumnDefinition column definition

func (*ColumnDefinition) Format

func (node *ColumnDefinition) Format(buf *TrackedBuffer)

Format ColumnDefinition

type Columns

type Columns []SelectExpr

Columns represents an insert column list. The syntax for Columns is a subset of SelectExprs. So, it's castable to a SelectExprs and can be analyzed as such.

func (Columns) Format

func (node Columns) Format(buf *TrackedBuffer)

type Comments

type Comments [][]byte

Comments represents a list of comments.

func (Comments) Format

func (node Comments) Format(buf *TrackedBuffer)

type Commit

type Commit struct {
}

Commit statement

func (*Commit) Format

func (node *Commit) Format(buf *TrackedBuffer)

func (*Commit) IStatement

func (node *Commit) IStatement()

func (*Commit) ITransactionStatement

func (node *Commit) ITransactionStatement()

type ComparisonExpr

type ComparisonExpr struct {
	Operator    string
	Left, Right ValExpr
}

ComparisonExpr represents a two-value comparison expression.

func (*ComparisonExpr) Format

func (node *ComparisonExpr) Format(buf *TrackedBuffer)

func (*ComparisonExpr) IBoolExpr

func (*ComparisonExpr) IBoolExpr()

func (*ComparisonExpr) IExpr

func (*ComparisonExpr) IExpr()

type CreateColumnDefinition

type CreateColumnDefinition struct {
	ColumnName *ColName
	ColumnDef  *ColumnDefinition
}

CreateColumnDefinition create column definition

func (*CreateColumnDefinition) Format

func (node *CreateColumnDefinition) Format(buf *TrackedBuffer)

Format CreateColumnDefinition

func (*CreateColumnDefinition) ICreateDefinition

func (node *CreateColumnDefinition) ICreateDefinition()

type CreateDefinition

type CreateDefinition interface {
	SQLNode
	ICreateDefinition()
}

CreateDefinition create definition

type CreateDefinitions

type CreateDefinitions []CreateDefinition

CreateDefinitions create definition list.

func (CreateDefinitions) Format

func (node CreateDefinitions) Format(buf *TrackedBuffer)

Format CreateDefinitions

type CreateForeignKeyDefinition

type CreateForeignKeyDefinition struct {
	Symbol       []byte
	IndexColumns IndexColNames
	ReferenceDef []byte
}

CreateForeignKeyDefinition create foreign key definition

func (*CreateForeignKeyDefinition) Format

func (node *CreateForeignKeyDefinition) Format(buf *TrackedBuffer)

Format CreateForeignKeyDefinition

func (*CreateForeignKeyDefinition) ICreateDefinition

func (node *CreateForeignKeyDefinition) ICreateDefinition()

type CreateIndex

type CreateIndex struct {
	Comments      Comments
	IndexCategory []byte
	Name          []byte
	Table         *TableName
	IndexType     []byte
	IndexColumns  IndexColNames
	IndexOption   []byte
}

CreateIndex create index statement

func (*CreateIndex) Format

func (node *CreateIndex) Format(buf *TrackedBuffer)

Format CreateIndex

func (*CreateIndex) IDDLStatement

func (node *CreateIndex) IDDLStatement()

func (*CreateIndex) IStatement

func (node *CreateIndex) IStatement()

type CreateIndexDefinition

type CreateIndexDefinition struct {
	Name         []byte
	IndexType    []byte
	IndexColumns IndexColNames
}

CreateIndexDefinition create index definition

func (*CreateIndexDefinition) Format

func (node *CreateIndexDefinition) Format(buf *TrackedBuffer)

Format CreateIndexDefinition

func (*CreateIndexDefinition) ICreateDefinition

func (node *CreateIndexDefinition) ICreateDefinition()

type CreatePrimaryKeyDefinition

type CreatePrimaryKeyDefinition struct {
	Symbol       []byte
	IndexType    []byte
	IndexColumns IndexColNames
}

CreatePrimaryKeyDefinition create primary key definition

func (*CreatePrimaryKeyDefinition) Format

func (node *CreatePrimaryKeyDefinition) Format(buf *TrackedBuffer)

Format CreatePrimaryKeyDefinition

func (*CreatePrimaryKeyDefinition) ICreateDefinition

func (node *CreatePrimaryKeyDefinition) ICreateDefinition()

type CreateTable

type CreateTable struct {
	Comments     Comments
	Table        *TableName
	CreateDefs   CreateDefinitions
	TableOptions OptionKeyValues
}

CreateTable create table statement

func (*CreateTable) Format

func (node *CreateTable) Format(buf *TrackedBuffer)

Format CreateTable

func (*CreateTable) IDDLStatement

func (node *CreateTable) IDDLStatement()

func (*CreateTable) IStatement

func (node *CreateTable) IStatement()

type CreateUniqueIndexDefinition

type CreateUniqueIndexDefinition struct {
	Symbol       []byte
	Name         []byte
	IndexType    []byte
	IndexColumns IndexColNames
}

CreateUniqueIndexDefinition create unique index definition

func (*CreateUniqueIndexDefinition) Format

func (node *CreateUniqueIndexDefinition) Format(buf *TrackedBuffer)

Format CreateUniqueIndexDefinition

func (*CreateUniqueIndexDefinition) ICreateDefinition

func (node *CreateUniqueIndexDefinition) ICreateDefinition()

type DDLStatement

type DDLStatement interface {
	IStatement()
	SQLNode
	IDDLStatement()
}

DDLStatement ddl statement

type DataType

type DataType struct {
	TypeName   string
	IsUnsigned bool
	IsZeroFill bool
	IsBinary   bool
	Charset    []byte
	Collate    []byte
}

DataType data type.

func (*DataType) Format

func (node *DataType) Format(buf *TrackedBuffer)

Format DataType

type Delete

type Delete struct {
	Comments Comments
	Table    *TableName
	Where    *Where
	OrderBy  OrderBy
	Limit    *Limit
}

Delete represents a DELETE statement.

func (*Delete) Format

func (node *Delete) Format(buf *TrackedBuffer)

func (*Delete) IStatement

func (node *Delete) IStatement()

type DisableKeysSpec

type DisableKeysSpec struct {
}

DisableKeysSpec disable keys specification

func (*DisableKeysSpec) Format

func (node *DisableKeysSpec) Format(buf *TrackedBuffer)

Format DisableKeysSpec

func (*DisableKeysSpec) IAlterSpecification

func (node *DisableKeysSpec) IAlterSpecification()

type DropColumnSpec

type DropColumnSpec struct {
	ColumnName *ColName
}

DropColumnSpec drop column specification

func (*DropColumnSpec) Format

func (node *DropColumnSpec) Format(buf *TrackedBuffer)

Format DropColumnSpec

func (*DropColumnSpec) IAlterSpecification

func (node *DropColumnSpec) IAlterSpecification()

type DropForeignKeySpec

type DropForeignKeySpec struct {
	Name []byte
}

DropForeignKeySpec drop foreign key specification

func (*DropForeignKeySpec) Format

func (node *DropForeignKeySpec) Format(buf *TrackedBuffer)

Format DropForeignKeySpec

func (*DropForeignKeySpec) IAlterSpecification

func (node *DropForeignKeySpec) IAlterSpecification()

type DropIndex

type DropIndex struct {
	Comments Comments
	Name     []byte
	Table    *TableName
}

DropIndex drop index

func (*DropIndex) Format

func (node *DropIndex) Format(buf *TrackedBuffer)

Format DropIndex

func (*DropIndex) IDDLStatement

func (node *DropIndex) IDDLStatement()

func (*DropIndex) IStatement

func (node *DropIndex) IStatement()

type DropIndexSpec

type DropIndexSpec struct {
	Name []byte
}

DropIndexSpec drop index specification

func (*DropIndexSpec) Format

func (node *DropIndexSpec) Format(buf *TrackedBuffer)

Format DropIndexSpec

func (*DropIndexSpec) IAlterSpecification

func (node *DropIndexSpec) IAlterSpecification()

type DropPrimaryKeySpec

type DropPrimaryKeySpec struct {
}

DropPrimaryKeySpec drop primary key specification

func (*DropPrimaryKeySpec) Format

func (node *DropPrimaryKeySpec) Format(buf *TrackedBuffer)

Format DropPrimaryKeySpec

func (*DropPrimaryKeySpec) IAlterSpecification

func (node *DropPrimaryKeySpec) IAlterSpecification()

type DropTable

type DropTable struct {
	Comments  Comments
	Name      *TableName
	RefOption []byte
}

DropTable drop table

func (*DropTable) Format

func (node *DropTable) Format(buf *TrackedBuffer)

Format DropTable

func (*DropTable) IDDLStatement

func (node *DropTable) IDDLStatement()

func (*DropTable) IStatement

func (node *DropTable) IStatement()

type EnableKeysSpec

type EnableKeysSpec struct {
}

EnableKeysSpec enable keys specification

func (*EnableKeysSpec) Format

func (node *EnableKeysSpec) Format(buf *TrackedBuffer)

Format EnableKeysSpec

func (*EnableKeysSpec) IAlterSpecification

func (node *EnableKeysSpec) IAlterSpecification()

type ExistsExpr

type ExistsExpr struct {
	Subquery *Subquery
}

ExistsExpr represents an EXISTS expression.

func (*ExistsExpr) Format

func (node *ExistsExpr) Format(buf *TrackedBuffer)

func (*ExistsExpr) IBoolExpr

func (*ExistsExpr) IBoolExpr()

func (*ExistsExpr) IExpr

func (*ExistsExpr) IExpr()

type Explain

type Explain struct {
	Statement
}

Explain select statement.

func (*Explain) Format

func (node *Explain) Format(buf *TrackedBuffer)

Format Explain.

func (*Explain) IStatement

func (node *Explain) IStatement()

type Expr

type Expr interface {
	IExpr()
	SQLNode
}

Expr represents an expression.

type FirstOrAfterColumn

type FirstOrAfterColumn struct {
	FirstOrAfter string
	ColumnName   *ColName
}

FirstOrAfterColumn first or after column

func (*FirstOrAfterColumn) Format

func (node *FirstOrAfterColumn) Format(buf *TrackedBuffer)

Format FirstOrAfterColumn

type FuncExpr

type FuncExpr struct {
	Name     []byte
	Distinct bool
	Exprs    ValExprs
}

FuncExpr represents a function call.

func (*FuncExpr) Format

func (node *FuncExpr) Format(buf *TrackedBuffer)

func (*FuncExpr) IExpr

func (*FuncExpr) IExpr()

func (*FuncExpr) IValExpr

func (*FuncExpr) IValExpr()

type GroupBy

type GroupBy []ValExpr

GroupBy represents a GROUP BY clause.

func (GroupBy) Format

func (node GroupBy) Format(buf *TrackedBuffer)

type IndexColName

type IndexColName struct {
	ColumnName *ColName
	Length     ValExpr
	AscOrDesc  string
}

IndexColName index column name

func (*IndexColName) Format

func (node *IndexColName) Format(buf *TrackedBuffer)

Format IndexColName

type IndexColNames

type IndexColNames []*IndexColName

IndexColNames index column name list

func (IndexColNames) Format

func (node IndexColNames) Format(buf *TrackedBuffer)

Format IndexColNames

type IndexHints

type IndexHints struct {
	Type    string
	Indexes [][]byte
}

IndexHints represents a list of index hints.

func (*IndexHints) Format

func (node *IndexHints) Format(buf *TrackedBuffer)

type Insert

type Insert struct {
	Comments Comments
	Ignore   string
	Table    *TableName
	Columns  Columns
	Rows     InsertRows
	OnDup    OnDup
}

Insert represents an INSERT statement.

func (*Insert) Format

func (node *Insert) Format(buf *TrackedBuffer)

func (*Insert) IStatement

func (node *Insert) IStatement()

type InsertRows

type InsertRows interface {
	IInsertRows()
	SQLNode
}

InsertRows represents the rows for an INSERT statement.

type JoinTableExpr

type JoinTableExpr struct {
	LeftExpr  TableExpr
	Join      string
	RightExpr TableExpr
	On        BoolExpr
}

JoinTableExpr represents a TableExpr that's a JOIN operation.

func (*JoinTableExpr) Format

func (node *JoinTableExpr) Format(buf *TrackedBuffer)

func (*JoinTableExpr) ITableExpr

func (*JoinTableExpr) ITableExpr()

type KillConnection

type KillConnection struct {
	ConnectionID NumVal
}

KillConnection kill connection statement.

func (*KillConnection) Format

func (node *KillConnection) Format(buf *TrackedBuffer)

Format KillConnection

func (*KillConnection) GetConnectionID

func (node *KillConnection) GetConnectionID() uint32

func (*KillConnection) IAdminStatement

func (node *KillConnection) IAdminStatement()

func (*KillConnection) IKillStatement

func (node *KillConnection) IKillStatement()

func (*KillConnection) IStatement

func (node *KillConnection) IStatement()

type KillQuery

type KillQuery struct {
	ConnectionID NumVal
}

KillQuery kill query statement

func (*KillQuery) Format

func (node *KillQuery) Format(buf *TrackedBuffer)

Format KillQuery

func (*KillQuery) GetConnectionID

func (node *KillQuery) GetConnectionID() uint32

func (*KillQuery) IAdminStatement

func (node *KillQuery) IAdminStatement()

func (*KillQuery) IKillStatement

func (node *KillQuery) IKillStatement()

func (*KillQuery) IStatement

func (node *KillQuery) IStatement()

type KillStatement

type KillStatement interface {
	AdminStatement
	IKillStatement()
	GetConnectionID() uint32
}

KillStatement kill statement.

type LikeExpr

type LikeExpr struct {
	Expr ValExpr
}

LikeExpr Expression

func (*LikeExpr) Format

func (node *LikeExpr) Format(buf *TrackedBuffer)

func (*LikeExpr) IExpr

func (*LikeExpr) IExpr()

type Limit

type Limit struct {
	Offset, Rowcount ValExpr
}

Limit represents a LIMIT clause.

func (*Limit) Format

func (node *Limit) Format(buf *TrackedBuffer)

func (*Limit) RewriteLimit

func (node *Limit) RewriteLimit() (*Limit, error)

type NonStarExpr

type NonStarExpr struct {
	Expr Expr
	As   []byte
}

NonStarExpr defines a non-'*' select expr.

func (*NonStarExpr) Format

func (node *NonStarExpr) Format(buf *TrackedBuffer)

func (*NonStarExpr) ISelectExpr

func (*NonStarExpr) ISelectExpr()

type NotExpr

type NotExpr struct {
	Expr BoolExpr
}

NotExpr represents a NOT expression.

func (*NotExpr) Format

func (node *NotExpr) Format(buf *TrackedBuffer)

func (*NotExpr) IBoolExpr

func (*NotExpr) IBoolExpr()

func (*NotExpr) IExpr

func (*NotExpr) IExpr()

type NullCheck

type NullCheck struct {
	Operator string
	Expr     ValExpr
}

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

func (*NullCheck) Format

func (node *NullCheck) Format(buf *TrackedBuffer)

func (*NullCheck) IBoolExpr

func (*NullCheck) IBoolExpr()

func (*NullCheck) IExpr

func (*NullCheck) IExpr()

type NullVal

type NullVal struct{}

NullVal represents a NULL value.

func (*NullVal) Format

func (node *NullVal) Format(buf *TrackedBuffer)

func (*NullVal) IExpr

func (*NullVal) IExpr()

func (*NullVal) IValExpr

func (*NullVal) IValExpr()

type NumVal

type NumVal []byte

NumVal represents a number.

func (NumVal) Format

func (node NumVal) Format(buf *TrackedBuffer)

func (NumVal) IExpr

func (NumVal) IExpr()

func (NumVal) IValExpr

func (NumVal) IValExpr()

type OnDup

type OnDup UpdateExprs

OnDup represents an ON DUPLICATE KEY clause.

func (OnDup) Format

func (node OnDup) Format(buf *TrackedBuffer)

type OptionKeyValue

type OptionKeyValue struct {
	Key   string
	Value string
}

OptionKeyValue option key value

func (*OptionKeyValue) Format

func (node *OptionKeyValue) Format(buf *TrackedBuffer)

Format OptionKeyValue

type OptionKeyValues

type OptionKeyValues []*OptionKeyValue

OptionKeyValues option key value list

func (OptionKeyValues) Format

func (node OptionKeyValues) Format(buf *TrackedBuffer)

Format OptionKeyValues

func (OptionKeyValues) IAlterSpecification

func (node OptionKeyValues) IAlterSpecification()

type OrExpr

type OrExpr struct {
	Left, Right BoolExpr
}

OrExpr represents an OR expression.

func (*OrExpr) Format

func (node *OrExpr) Format(buf *TrackedBuffer)

func (*OrExpr) IBoolExpr

func (*OrExpr) IBoolExpr()

func (*OrExpr) IExpr

func (*OrExpr) IExpr()

type Order

type Order struct {
	Expr      ValExpr
	Direction string
}

Order represents an ordering expression.

func (*Order) Format

func (node *Order) Format(buf *TrackedBuffer)

type OrderBy

type OrderBy []*Order

OrderBy represents an ORDER By clause.

func (OrderBy) Format

func (node OrderBy) Format(buf *TrackedBuffer)

type ParenBoolExpr

type ParenBoolExpr struct {
	Expr BoolExpr
}

ParenBoolExpr represents a parenthesized boolean expression.

func (*ParenBoolExpr) Format

func (node *ParenBoolExpr) Format(buf *TrackedBuffer)

func (*ParenBoolExpr) IBoolExpr

func (*ParenBoolExpr) IBoolExpr()

func (*ParenBoolExpr) IExpr

func (*ParenBoolExpr) IExpr()

type ParenTableExpr

type ParenTableExpr struct {
	Expr TableExpr
}

ParenTableExpr represents a parenthesized TableExpr.

func (*ParenTableExpr) Format

func (node *ParenTableExpr) Format(buf *TrackedBuffer)

func (*ParenTableExpr) ITableExpr

func (*ParenTableExpr) ITableExpr()

type RangeCond

type RangeCond struct {
	Operator string
	Left     ValExpr
	From, To ValExpr
}

RangeCond represents a BETWEEN or a NOT BETWEEN expression.

func (*RangeCond) Format

func (node *RangeCond) Format(buf *TrackedBuffer)

func (*RangeCond) IBoolExpr

func (*RangeCond) IBoolExpr()

func (*RangeCond) IExpr

func (*RangeCond) IExpr()

type RenameTable

type RenameTable struct {
	Comments Comments
	OldName  *TableName
	NewName  *TableName
}

RenameTable rename table

func (*RenameTable) Format

func (node *RenameTable) Format(buf *TrackedBuffer)

Format RenameTable

func (*RenameTable) IDDLStatement

func (node *RenameTable) IDDLStatement()

func (*RenameTable) IStatement

func (node *RenameTable) IStatement()

type Replace

type Replace struct {
	Comments Comments
	Table    *TableName
	Columns  Columns
	Rows     InsertRows
}

Replace represents an REPLACE statement.

func (*Replace) Format

func (node *Replace) Format(buf *TrackedBuffer)

func (*Replace) IStatement

func (node *Replace) IStatement()

type Rollback

type Rollback struct {
}

Rollback statement

func (*Rollback) Format

func (node *Rollback) Format(buf *TrackedBuffer)

func (*Rollback) IStatement

func (node *Rollback) IStatement()

func (*Rollback) ITransactionStatement

func (node *Rollback) ITransactionStatement()

type SQLNode

type SQLNode interface {
	Format(buf *TrackedBuffer)
}

SQLNode defines the interface for all nodes generated by the parser.

type Select

type Select struct {
	Comments    Comments
	Distinct    string
	SelectExprs SelectExprs
	From        TableExprs
	Where       *Where
	GroupBy     GroupBy
	Having      *Where
	OrderBy     OrderBy
	Limit       *Limit
	Lock        string
}

Select represents a SELECT statement.

func (*Select) Format

func (node *Select) Format(buf *TrackedBuffer)

Format Select.

func (*Select) IInsertRows

func (node *Select) IInsertRows()

func (*Select) ISelectStatement

func (node *Select) ISelectStatement()

func (*Select) IStatement

func (node *Select) IStatement()

type SelectExpr

type SelectExpr interface {
	ISelectExpr()
	SQLNode
}

SelectExpr represents a SELECT expression.

type SelectExprs

type SelectExprs []SelectExpr

SelectExprs represents SELECT expressions.

func (SelectExprs) Format

func (node SelectExprs) Format(buf *TrackedBuffer)

type SelectStatement

type SelectStatement interface {
	IStatement()
	ISelectStatement()
	IInsertRows()
	SQLNode
}

SelectStatement any SELECT statement.

type SetCharset

type SetCharset struct {
	Comments Comments
	Scope    string // SESSION or GLOBAL
	Charset  string
}

SetCharset set charset.

func (*SetCharset) Format

func (node *SetCharset) Format(buf *TrackedBuffer)

func (*SetCharset) ISetStatement

func (node *SetCharset) ISetStatement()

func (*SetCharset) IStatement

func (node *SetCharset) IStatement()

type SetNames

type SetNames struct {
	Comments Comments
	Names    string
	Collate  string
}

SetNames set NAMES.

func (*SetNames) Format

func (node *SetNames) Format(buf *TrackedBuffer)

func (*SetNames) ISetStatement

func (node *SetNames) ISetStatement()

func (*SetNames) IStatement

func (node *SetNames) IStatement()

type SetStatement

type SetStatement interface {
	IStatement()
	ISetStatement()
	SQLNode
}

SetStatement set statement

type SetTransactionIsolationLevel

type SetTransactionIsolationLevel struct {
	Comments       Comments
	Scope          string // SESSION or GLOBAL
	IsolationLevel string
}

SetTransactionIsolationLevel represents a SET TRANSACTION ISOLATION LEVEL statement.

func (*SetTransactionIsolationLevel) Format

func (node *SetTransactionIsolationLevel) Format(buf *TrackedBuffer)

func (*SetTransactionIsolationLevel) ISetStatement

func (node *SetTransactionIsolationLevel) ISetStatement()

func (*SetTransactionIsolationLevel) IStatement

func (node *SetTransactionIsolationLevel) IStatement()

type SetVariable

type SetVariable struct {
	Comments Comments
	Scope    string // SESSION or GLOBAL
	Exprs    UpdateExprs
}

SetVariable set variable assignment

func (*SetVariable) Format

func (node *SetVariable) Format(buf *TrackedBuffer)

func (*SetVariable) ISetStatement

func (node *SetVariable) ISetStatement()

func (*SetVariable) IStatement

func (node *SetVariable) IStatement()

type ShowCharset

type ShowCharset struct {
	Comments    Comments
	LikeOrWhere Expr
}

ShowCharset statement

func (*ShowCharset) Format

func (node *ShowCharset) Format(buf *TrackedBuffer)

Format ShowCharset

func (*ShowCharset) IShowStatement

func (node *ShowCharset) IShowStatement()

func (*ShowCharset) IStatement

func (node *ShowCharset) IStatement()

type ShowCollation

type ShowCollation struct {
	Comments    Comments
	LikeOrWhere Expr
}

ShowCollation statement

func (*ShowCollation) Format

func (node *ShowCollation) Format(buf *TrackedBuffer)

Format ShowCollation

func (*ShowCollation) IShowStatement

func (node *ShowCollation) IShowStatement()

func (*ShowCollation) IStatement

func (node *ShowCollation) IStatement()

type ShowColumns

type ShowColumns struct {
	Comments    Comments
	From        *TableName
	LikeOrWhere Expr
}

ShowColumns statement

func (*ShowColumns) Format

func (node *ShowColumns) Format(buf *TrackedBuffer)

Format ShowColumns

func (*ShowColumns) IShowStatement

func (node *ShowColumns) IShowStatement()

func (*ShowColumns) IStatement

func (node *ShowColumns) IStatement()

type ShowCreateDatabase

type ShowCreateDatabase struct {
	Comments Comments
	Name     *TableName
}

ShowCreateDatabase statement

func (*ShowCreateDatabase) Format

func (node *ShowCreateDatabase) Format(buf *TrackedBuffer)

Format ShowCreateDatabase

func (*ShowCreateDatabase) IShowStatement

func (node *ShowCreateDatabase) IShowStatement()

func (*ShowCreateDatabase) IStatement

func (node *ShowCreateDatabase) IStatement()

type ShowCreateFunction

type ShowCreateFunction struct {
	Comments Comments
	Name     *TableName
}

ShowCreateFunction statement

func (*ShowCreateFunction) Format

func (node *ShowCreateFunction) Format(buf *TrackedBuffer)

Format ShowCreateFunction

func (*ShowCreateFunction) IShowStatement

func (node *ShowCreateFunction) IShowStatement()

func (*ShowCreateFunction) IStatement

func (node *ShowCreateFunction) IStatement()

type ShowCreateProcedure

type ShowCreateProcedure struct {
	Comments Comments
	Name     *TableName
}

ShowCreateProcedure statement

func (*ShowCreateProcedure) Format

func (node *ShowCreateProcedure) Format(buf *TrackedBuffer)

Format ShowCreateProcedure

func (*ShowCreateProcedure) IShowStatement

func (node *ShowCreateProcedure) IShowStatement()

func (*ShowCreateProcedure) IStatement

func (node *ShowCreateProcedure) IStatement()

type ShowCreateTable

type ShowCreateTable struct {
	Comments Comments
	Name     *TableName
}

ShowCreateTable statement

func (*ShowCreateTable) Format

func (node *ShowCreateTable) Format(buf *TrackedBuffer)

Format ShowCreateTable

func (*ShowCreateTable) IShowStatement

func (node *ShowCreateTable) IShowStatement()

func (*ShowCreateTable) IStatement

func (node *ShowCreateTable) IStatement()

type ShowCreateTrigger

type ShowCreateTrigger struct {
	Comments Comments
	Name     *TableName
}

ShowCreateTrigger statement

func (*ShowCreateTrigger) Format

func (node *ShowCreateTrigger) Format(buf *TrackedBuffer)

Format ShowCreateTrigger

func (*ShowCreateTrigger) IShowStatement

func (node *ShowCreateTrigger) IShowStatement()

func (*ShowCreateTrigger) IStatement

func (node *ShowCreateTrigger) IStatement()

type ShowCreateView

type ShowCreateView struct {
	Comments Comments
	Name     *TableName
}

ShowCreateView statement

func (*ShowCreateView) Format

func (node *ShowCreateView) Format(buf *TrackedBuffer)

Format ShowCreateView

func (*ShowCreateView) IShowStatement

func (node *ShowCreateView) IShowStatement()

func (*ShowCreateView) IStatement

func (node *ShowCreateView) IStatement()

type ShowDatabases

type ShowDatabases struct {
	Comments    Comments
	LikeOrWhere Expr
}

ShowDatabases statement

func (*ShowDatabases) Format

func (node *ShowDatabases) Format(buf *TrackedBuffer)

Format ShowDatabases

func (*ShowDatabases) IShowStatement

func (node *ShowDatabases) IShowStatement()

func (*ShowDatabases) IStatement

func (node *ShowDatabases) IStatement()

type ShowEngines

type ShowEngines struct {
}

ShowEngines statement

func (*ShowEngines) Format

func (node *ShowEngines) Format(buf *TrackedBuffer)

Format ShowEngines

func (*ShowEngines) IShowStatement

func (node *ShowEngines) IShowStatement()

func (*ShowEngines) IStatement

func (node *ShowEngines) IStatement()

type ShowFullColumns

type ShowFullColumns struct {
	Comments    Comments
	From        *TableName
	LikeOrWhere Expr
}

ShowFullColumns statement

func (*ShowFullColumns) Format

func (node *ShowFullColumns) Format(buf *TrackedBuffer)

Format ShowFullColumns

func (*ShowFullColumns) IShowStatement

func (node *ShowFullColumns) IShowStatement()

func (*ShowFullColumns) IStatement

func (node *ShowFullColumns) IStatement()

type ShowFullProcessList

type ShowFullProcessList struct {
	Comments Comments
}

ShowFullProcessList statement

func (*ShowFullProcessList) Format

func (node *ShowFullProcessList) Format(buf *TrackedBuffer)

Format ShowFullProcessList

func (*ShowFullProcessList) IShowStatement

func (node *ShowFullProcessList) IShowStatement()

func (*ShowFullProcessList) IStatement

func (node *ShowFullProcessList) IStatement()

type ShowFullTables

type ShowFullTables struct {
	Comments    Comments
	From        *TableName
	LikeOrWhere Expr
}

ShowFullTables statement

func (*ShowFullTables) Format

func (node *ShowFullTables) Format(buf *TrackedBuffer)

Format ShowFullTables

func (*ShowFullTables) IShowStatement

func (node *ShowFullTables) IShowStatement()

func (*ShowFullTables) IStatement

func (node *ShowFullTables) IStatement()

type ShowFunctionStatus

type ShowFunctionStatus struct {
	Comments    Comments
	LikeOrWhere Expr
}

ShowFunctionStatus statement

func (*ShowFunctionStatus) Format

func (node *ShowFunctionStatus) Format(buf *TrackedBuffer)

Format ShowFunctionStatus

func (*ShowFunctionStatus) IShowStatement

func (node *ShowFunctionStatus) IShowStatement()

func (*ShowFunctionStatus) IStatement

func (node *ShowFunctionStatus) IStatement()

type ShowIndex

type ShowIndex struct {
	Comments Comments
	From     *TableName
	Where    BoolExpr
}

ShowIndex statement

func (*ShowIndex) Format

func (node *ShowIndex) Format(buf *TrackedBuffer)

Format ShowIndex

func (*ShowIndex) IShowStatement

func (node *ShowIndex) IShowStatement()

func (*ShowIndex) IStatement

func (node *ShowIndex) IStatement()

type ShowPlugins

type ShowPlugins struct {
}

ShowPlugins statement

func (*ShowPlugins) Format

func (node *ShowPlugins) Format(buf *TrackedBuffer)

Format ShowPlugins

func (*ShowPlugins) IShowStatement

func (node *ShowPlugins) IShowStatement()

func (*ShowPlugins) IStatement

func (node *ShowPlugins) IStatement()

type ShowProcedureStatus

type ShowProcedureStatus struct {
	Comments    Comments
	LikeOrWhere Expr
}

ShowProcedureStatus statement

func (*ShowProcedureStatus) Format

func (node *ShowProcedureStatus) Format(buf *TrackedBuffer)

Format ShowProcedureStatus

func (*ShowProcedureStatus) IShowStatement

func (node *ShowProcedureStatus) IShowStatement()

func (*ShowProcedureStatus) IStatement

func (node *ShowProcedureStatus) IStatement()

type ShowProcessList

type ShowProcessList struct {
	Comments Comments
}

ShowProcessList statement

func (*ShowProcessList) Format

func (node *ShowProcessList) Format(buf *TrackedBuffer)

Format ShowProcessList

func (*ShowProcessList) IShowStatement

func (node *ShowProcessList) IShowStatement()

func (*ShowProcessList) IStatement

func (node *ShowProcessList) IStatement()

type ShowProfiles

type ShowProfiles struct {
}

ShowProfiles statement

func (*ShowProfiles) Format

func (node *ShowProfiles) Format(buf *TrackedBuffer)

Format ShowProfiles

func (*ShowProfiles) IShowStatement

func (node *ShowProfiles) IShowStatement()

func (*ShowProfiles) IStatement

func (node *ShowProfiles) IStatement()

type ShowSlaveStatus

type ShowSlaveStatus struct {
	Comments Comments
}

ShowSlaveStatus statement

func (*ShowSlaveStatus) Format

func (node *ShowSlaveStatus) Format(buf *TrackedBuffer)

Format ShowSlaveStatus

func (*ShowSlaveStatus) IShowStatement

func (node *ShowSlaveStatus) IShowStatement()

func (*ShowSlaveStatus) IStatement

func (node *ShowSlaveStatus) IStatement()

type ShowStatement

type ShowStatement interface {
	IStatement()
	IShowStatement()
	SQLNode
}

ShowStatement show statement

type ShowStatus

type ShowStatus struct {
	Comments    Comments
	Scope       string // GLOBAL or SESSION
	LikeOrWhere Expr
}

ShowStatus statement

func (*ShowStatus) Format

func (node *ShowStatus) Format(buf *TrackedBuffer)

Format ShowStatus

func (*ShowStatus) IShowStatement

func (node *ShowStatus) IShowStatement()

func (*ShowStatus) IStatement

func (node *ShowStatus) IStatement()

type ShowTableStatus

type ShowTableStatus struct {
	Comments    Comments
	From        *TableName
	LikeOrWhere Expr
}

ShowTableStatus statement

func (*ShowTableStatus) Format

func (node *ShowTableStatus) Format(buf *TrackedBuffer)

Format ShowTableStatus

func (*ShowTableStatus) IShowStatement

func (node *ShowTableStatus) IShowStatement()

func (*ShowTableStatus) IStatement

func (node *ShowTableStatus) IStatement()

type ShowTables

type ShowTables struct {
	Comments    Comments
	From        *TableName
	LikeOrWhere Expr
}

ShowTables statement

func (*ShowTables) Format

func (node *ShowTables) Format(buf *TrackedBuffer)

Format ShowTables

func (*ShowTables) IShowStatement

func (node *ShowTables) IShowStatement()

func (*ShowTables) IStatement

func (node *ShowTables) IStatement()

type ShowTriggers

type ShowTriggers struct {
	Comments    Comments
	From        *TableName
	LikeOrWhere Expr
}

ShowTriggers statement

func (*ShowTriggers) Format

func (node *ShowTriggers) Format(buf *TrackedBuffer)

Format ShowTriggers

func (*ShowTriggers) IShowStatement

func (node *ShowTriggers) IShowStatement()

func (*ShowTriggers) IStatement

func (node *ShowTriggers) IStatement()

type ShowVariables

type ShowVariables struct {
	Comments    Comments
	Scope       string // GLOBAL or SESSION
	LikeOrWhere Expr
}

ShowVariables statement

func (*ShowVariables) Format

func (node *ShowVariables) Format(buf *TrackedBuffer)

Format ShowVariables

func (*ShowVariables) IShowStatement

func (node *ShowVariables) IShowStatement()

func (*ShowVariables) IStatement

func (node *ShowVariables) IStatement()

type SimpleSelect

type SimpleSelect struct {
	Comments    Comments
	Distinct    string
	SelectExprs SelectExprs
	Limit       *Limit
}

SimpleSelect no from and where statement.

func (*SimpleSelect) Format

func (node *SimpleSelect) Format(buf *TrackedBuffer)

func (*SimpleSelect) IInsertRows

func (*SimpleSelect) IInsertRows()

func (*SimpleSelect) ISelectStatement

func (*SimpleSelect) ISelectStatement()

func (*SimpleSelect) IStatement

func (*SimpleSelect) IStatement()

type SimpleTableExpr

type SimpleTableExpr interface {
	ISimpleTableExpr()
	SQLNode
}

SimpleTableExpr represents a simple table expression.

type SpaceSplitExpr

type SpaceSplitExpr struct {
	Name string
	Expr []byte
}

SpaceSplitExpr represents an space split expression.

func (*SpaceSplitExpr) Format

func (node *SpaceSplitExpr) Format(buf *TrackedBuffer)

type SpaceSplitExprs

type SpaceSplitExprs []*SpaceSplitExpr

SpaceSplitExprs represents a list of space split expressions.

func (SpaceSplitExprs) Format

func (node SpaceSplitExprs) Format(buf *TrackedBuffer)

type StarExpr

type StarExpr struct {
	TableName []byte
}

StarExpr defines a '*' or 'table.*' expression.

func (*StarExpr) Format

func (node *StarExpr) Format(buf *TrackedBuffer)

func (*StarExpr) ISelectExpr

func (*StarExpr) ISelectExpr()

type Statement

type Statement interface {
	IStatement()
	SQLNode
}

Statement represents a statement.

func Parse

func Parse(sql string) (Statement, error)

Parse parses the sql and returns a Statement, which is the AST representation of the query.

type StrVal

type StrVal []byte

StrVal represents a string value.

func (StrVal) Format

func (node StrVal) Format(buf *TrackedBuffer)

func (StrVal) IExpr

func (StrVal) IExpr()

func (StrVal) IValExpr

func (StrVal) IValExpr()

type Subquery

type Subquery struct {
	Select SelectStatement
}

Subquery represents a subquery.

func (*Subquery) Format

func (node *Subquery) Format(buf *TrackedBuffer)

func (*Subquery) IExpr

func (*Subquery) IExpr()

func (*Subquery) ISimpleTableExpr

func (*Subquery) ISimpleTableExpr()

func (*Subquery) ITuple

func (*Subquery) ITuple()

func (*Subquery) IValExpr

func (*Subquery) IValExpr()

type TableExpr

type TableExpr interface {
	ITableExpr()
	SQLNode
}

TableExpr represents a table expression.

type TableExprs

type TableExprs []TableExpr

TableExprs represents a list of table expressions.

func (TableExprs) Format

func (node TableExprs) Format(buf *TrackedBuffer)

type TableName

type TableName struct {
	Name, Qualifier []byte
}

TableName represents a table name.

func (*TableName) Format

func (node *TableName) Format(buf *TrackedBuffer)

func (*TableName) ISimpleTableExpr

func (*TableName) ISimpleTableExpr()

type Tokenizer

type Tokenizer struct {
	InStream      *strings.Reader
	AllowComments bool
	ForceEOF      bool

	Position int

	LastError string

	ParseTree Statement
	// contains filtered or unexported fields
}

Tokenizer is the struct used to generate SQL tokens for the parser.

func NewStringTokenizer

func NewStringTokenizer(sql string) *Tokenizer

NewStringTokenizer creates a new Tokenizer for the sql string.

func (*Tokenizer) Error

func (tkn *Tokenizer) Error(err string)

Error is called by go yacc if there's a parsing error.

func (*Tokenizer) Lex

func (tkn *Tokenizer) Lex(lval *yySymType) int

Lex returns the next token form the Tokenizer. This function is used by go yacc.

func (*Tokenizer) Next

func (tkn *Tokenizer) Next(buffer *bytes.Buffer)

Next char.

func (*Tokenizer) Scan

func (tkn *Tokenizer) Scan() (int, []byte)

Scan scans the tokenizer for the next token and returns the token type and an optional value.

type TrackedBuffer

type TrackedBuffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

TrackedBuffer is used to rebuild a query from the ast. bindLocations keeps track of locations in the buffer that use bind variables for efficient future substitutions. nodeFormatter is the formatting function the buffer will use to format a node. By default(nil), it's FormatNode. But you can supply a different formatting function if you want to generate a query that's different from the default.

func NewTrackedBuffer

func NewTrackedBuffer(nodeFormatter func(buf *TrackedBuffer, node SQLNode)) *TrackedBuffer

NewTrackedBuffer create TrackedBuffer

func (*TrackedBuffer) Fprintf

func (buf *TrackedBuffer) Fprintf(format string, values ...interface{})

Fprintf mimics fmt.Fprintf, but limited to Node(%v), Node.Value(%s) and string(%s). It also allows a %a for a value argument, in which case it adds tracking info for future substitutions.

func (*TrackedBuffer) WriteArg

func (buf *TrackedBuffer) WriteArg(arg string)

WriteArg write argument.

type TransactionStatement

type TransactionStatement interface {
	IStatement()
	ITransactionStatement()
	SQLNode
}

TransactionStatement Transaction Statement

type Tuple

type Tuple interface {
	ITuple()
	ValExpr
}

Tuple represents a tuple. It can be ValTuple, Subquery.

type UnaryExpr

type UnaryExpr struct {
	Operator byte
	Expr     Expr
}

UnaryExpr represents a unary value expression.

func (*UnaryExpr) Format

func (node *UnaryExpr) Format(buf *TrackedBuffer)

func (*UnaryExpr) IExpr

func (*UnaryExpr) IExpr()

func (*UnaryExpr) IValExpr

func (*UnaryExpr) IValExpr()

type Union

type Union struct {
	Type        string
	Left, Right SelectStatement
}

Union represents a UNION statement.

func (*Union) Format

func (node *Union) Format(buf *TrackedBuffer)

func (*Union) IInsertRows

func (node *Union) IInsertRows()

func (*Union) ISelectStatement

func (node *Union) ISelectStatement()

func (*Union) IStatement

func (node *Union) IStatement()

type Update

type Update struct {
	Comments Comments
	Table    *TableName
	Exprs    UpdateExprs
	Where    *Where
	OrderBy  OrderBy
	Limit    *Limit
}

Update represents an UPDATE statement.

func (*Update) Format

func (node *Update) Format(buf *TrackedBuffer)

func (*Update) IStatement

func (node *Update) IStatement()

type UpdateExpr

type UpdateExpr struct {
	Name *ColName
	Expr ValExpr
}

UpdateExpr represents an update expression.

func (*UpdateExpr) Format

func (node *UpdateExpr) Format(buf *TrackedBuffer)

type UpdateExprs

type UpdateExprs []*UpdateExpr

UpdateExprs represents a list of update expressions.

func (UpdateExprs) Format

func (node UpdateExprs) Format(buf *TrackedBuffer)

type UseDB

type UseDB struct {
	DB string
}

UseDB statement

func (*UseDB) Format

func (node *UseDB) Format(buf *TrackedBuffer)

func (*UseDB) IStatement

func (node *UseDB) IStatement()

type ValArg

type ValArg []byte

ValArg represents a named bind var argument.

func (ValArg) Format

func (node ValArg) Format(buf *TrackedBuffer)

func (ValArg) IExpr

func (ValArg) IExpr()

func (ValArg) IValExpr

func (ValArg) IValExpr()

type ValExpr

type ValExpr interface {
	IValExpr()
	Expr
}

ValExpr represents a value expression.

func CheckColumnInBoolExpr

func CheckColumnInBoolExpr(expr BoolExpr, colName string) (strOrNumValue ValExpr, err error)

CheckColumnInBoolExpr check if exists or not. strOrNumValue: if nil, mean no value or has different value.

func CheckColumnInInsertOrReplace

func CheckColumnInInsertOrReplace(columns Columns, insertRows InsertRows, onDup OnDup, colName string) (strOrNumValue ValExpr, err error)

CheckColumnInInsertOrReplace check shard key should exists in columns, not in dup expers, has same shard key's value in rows.

func CheckColumnInSelect

func CheckColumnInSelect(statement SelectStatement, colName string) (strOrNumValue ValExpr, err error)

CheckColumnInSelect check shard key should exists in where and join expression, and has same shard key's value in it.

func CheckColumnInTableExpr

func CheckColumnInTableExpr(tabExpr TableExpr, colName string) (strOrNumValue ValExpr, err error)

CheckColumnInTableExpr check shard key should exists in table expression, and has same shard key's value in it.

type ValExprs

type ValExprs []ValExpr

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

func (ValExprs) Format

func (node ValExprs) Format(buf *TrackedBuffer)

type ValTuple

type ValTuple ValExprs

ValTuple represents a tuple of actual values.

func (ValTuple) Format

func (node ValTuple) Format(buf *TrackedBuffer)

func (ValTuple) IExpr

func (ValTuple) IExpr()

func (ValTuple) ITuple

func (ValTuple) ITuple()

func (ValTuple) IValExpr

func (ValTuple) IValExpr()

type Values

type Values []Tuple

Values represents a VALUES clause.

func (Values) Format

func (node Values) Format(buf *TrackedBuffer)

func (Values) IInsertRows

func (Values) IInsertRows()

type When

type When struct {
	Cond BoolExpr
	Val  ValExpr
}

When represents a WHEN sub-expression.

func (*When) Format

func (node *When) Format(buf *TrackedBuffer)

type Where

type Where struct {
	Type string
	Expr BoolExpr
}

Where represents a WHERE or HAVING clause.

func NewWhere

func NewWhere(typ string, expr BoolExpr) *Where

NewWhere creates a WHERE or HAVING clause out of a BoolExpr. If the expression is nil, it returns nil.

func (*Where) Format

func (node *Where) Format(buf *TrackedBuffer)

type WhereExpr

type WhereExpr struct {
	Expr BoolExpr
}

WhereExpr Expression

func (*WhereExpr) Format

func (node *WhereExpr) Format(buf *TrackedBuffer)

func (*WhereExpr) IExpr

func (*WhereExpr) IExpr()

Directories

Path Synopsis
Package sqltypes implements interfaces and types that represent SQL values.
Package sqltypes implements interfaces and types that represent SQL values.

Jump to

Keyboard shortcuts

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