ast

package
v0.0.0-...-74d5ce4 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ast is the abstract syntax tree parsed from a SQL statement by parser. It can be analysed and transformed by optimizer.

Index

Constants

View Source
const (
	FlagConstant       uint64 = 0
	FlagHasParamMarker uint64 = 1 << iota
	FlagHasFunc
	FlagHasReference
	FlagHasAggregateFunc
	FlagHasSubquery
	FlagHasVariable
	FlagHasDefault
	FlagPreEvaluated
)

Flags indicates whether an expression contains certain types of expression.

View Source
const (
	RowFormatDefault uint64 = iota + 1
	RowFormatDynamic
	RowFormatFixed
	RowFormatCompressed
	RowFormatRedundant
	RowFormatCompact
)

RowFormat types

View Source
const (
	ShowNone = iota
	ShowEngines
	ShowDatabases
	ShowTables
	ShowTableStatus
	ShowColumns
	ShowWarnings
	ShowCharset
	ShowVariables
	ShowStatus
	ShowCollation
	ShowCreateTable
	ShowGrants
	ShowTriggers
	ShowProcedureStatus
	ShowIndex
	ShowProcessList
	ShowCreateDatabase
	ShowEvents
	ShowStatsMeta
	ShowStatsHistograms
	ShowStatsBuckets
	ShowPlugins
)

Show statement types.

View Source
const (
	LogicAnd   = "and"
	Cast       = "cast"
	LeftShift  = "leftshift"
	RightShift = "rightshift"
	LogicOr    = "or"
	GE         = "ge"
	LE         = "le"
	EQ         = "eq"
	NE         = "ne"
	LT         = "lt"
	GT         = "gt"
	Plus       = "plus"
	Minus      = "minus"
	And        = "bitand"
	Or         = "bitor"
	Mod        = "mod"
	Xor        = "bitxor"
	Div        = "div"
	Mul        = "mul"
	UnaryNot   = "not" // Avoid name conflict with Not in github/pingcap/check.
	BitNeg     = "bitneg"
	IntDiv     = "intdiv"
	LogicXor   = "xor"
	NullEQ     = "nulleq"
	UnaryPlus  = "unaryplus"
	UnaryMinus = "unaryminus"
	In         = "in"
	Like       = "like"
	Case       = "case"
	Regexp     = "regexp"
	IsNull     = "isnull"
	IsTruth    = "istrue"  // Avoid name conflict with IsTrue in github/pingcap/check.
	IsFalsity  = "isfalse" // Avoid name conflict with IsFalse in github/pingcap/check.
	RowFunc    = "row"
	SetVar     = "setvar"
	GetVar     = "getvar"
	Values     = "values"
	BitCount   = "bit_count"

	// common functions
	Coalesce = "coalesce"
	Greatest = "greatest"
	Least    = "least"
	Interval = "interval"

	// math functions
	Abs      = "abs"
	Acos     = "acos"
	Asin     = "asin"
	Atan     = "atan"
	Atan2    = "atan2"
	Ceil     = "ceil"
	Ceiling  = "ceiling"
	Conv     = "conv"
	Cos      = "cos"
	Cot      = "cot"
	CRC32    = "crc32"
	Degrees  = "degrees"
	Exp      = "exp"
	Floor    = "floor"
	Ln       = "ln"
	Log      = "log"
	Log2     = "log2"
	Log10    = "log10"
	PI       = "pi"
	Pow      = "pow"
	Power    = "power"
	Radians  = "radians"
	Rand     = "rand"
	Round    = "round"
	Sign     = "sign"
	Sin      = "sin"
	Sqrt     = "sqrt"
	Tan      = "tan"
	Truncate = "truncate"

	// time functions
	AddDate          = "adddate"
	AddTime          = "addtime"
	ConvertTz        = "convert_tz"
	Curdate          = "curdate"
	CurrentDate      = "current_date"
	CurrentTime      = "current_time"
	CurrentTimestamp = "current_timestamp"
	Curtime          = "curtime"
	Date             = "date"
	DateLiteral      = "dateliteral"
	DateAdd          = "date_add"
	DateFormat       = "date_format"
	DateSub          = "date_sub"
	DateDiff         = "datediff"
	Day              = "day"
	DayName          = "dayname"
	DayOfMonth       = "dayofmonth"
	DayOfWeek        = "dayofweek"
	DayOfYear        = "dayofyear"
	Extract          = "extract"
	FromDays         = "from_days"
	FromUnixTime     = "from_unixtime"
	GetFormat        = "get_format"
	Hour             = "hour"
	LocalTime        = "localtime"
	LocalTimestamp   = "localtimestamp"
	MakeDate         = "makedate"
	MakeTime         = "maketime"
	MicroSecond      = "microsecond"
	Minute           = "minute"
	Month            = "month"
	MonthName        = "monthname"
	Now              = "now"
	PeriodAdd        = "period_add"
	PeriodDiff       = "period_diff"
	Quarter          = "quarter"
	SecToTime        = "sec_to_time"
	Second           = "second"
	StrToDate        = "str_to_date"
	SubDate          = "subdate"
	SubTime          = "subtime"
	Sysdate          = "sysdate"
	Time             = "time"
	TimeFormat       = "time_format"
	TimeToSec        = "time_to_sec"
	TimeDiff         = "timediff"
	Timestamp        = "timestamp"
	TimestampAdd     = "timestampadd"
	TimestampDiff    = "timestampdiff"
	ToDays           = "to_days"
	ToSeconds        = "to_seconds"
	UnixTimestamp    = "unix_timestamp"
	UTCDate          = "utc_date"
	UTCTime          = "utc_time"
	UTCTimestamp     = "utc_timestamp"
	Week             = "week"
	Weekday          = "weekday"
	WeekOfYear       = "weekofyear"
	Year             = "year"
	YearWeek         = "yearweek"
	LastDay          = "last_day"

	// string functions
	ASCII           = "ascii"
	Bin             = "bin"
	Concat          = "concat"
	ConcatWS        = "concat_ws"
	Convert         = "convert"
	Elt             = "elt"
	ExportSet       = "export_set"
	Field           = "field"
	Format          = "format"
	FromBase64      = "from_base64"
	InsertFunc      = "insert_func"
	Instr           = "instr"
	Lcase           = "lcase"
	Left            = "left"
	Length          = "length"
	LoadFile        = "load_file"
	Locate          = "locate"
	Lower           = "lower"
	Lpad            = "lpad"
	LTrim           = "ltrim"
	MakeSet         = "make_set"
	Mid             = "mid"
	Oct             = "oct"
	Ord             = "ord"
	Position        = "position"
	Quote           = "quote"
	Repeat          = "repeat"
	Replace         = "replace"
	Reverse         = "reverse"
	Right           = "right"
	RTrim           = "rtrim"
	Space           = "space"
	Strcmp          = "strcmp"
	Substring       = "substring"
	Substr          = "substr"
	SubstringIndex  = "substring_index"
	ToBase64        = "to_base64"
	Trim            = "trim"
	Upper           = "upper"
	Ucase           = "ucase"
	Hex             = "hex"
	Unhex           = "unhex"
	Rpad            = "rpad"
	BitLength       = "bit_length"
	CharFunc        = "char_func"
	CharLength      = "char_length"
	CharacterLength = "character_length"
	FindInSet       = "find_in_set"

	// information functions
	Benchmark    = "benchmark"
	Charset      = "charset"
	Coercibility = "coercibility"
	Collation    = "collation"
	ConnectionID = "connection_id"
	CurrentUser  = "current_user"
	Database     = "database"
	FoundRows    = "found_rows"
	LastInsertId = "last_insert_id"
	RowCount     = "row_count"
	Schema       = "schema"
	SessionUser  = "session_user"
	SystemUser   = "system_user"
	User         = "user"
	Version      = "version"
	TiDBVersion  = "tidb_version"

	// control functions
	If     = "if"
	Ifnull = "ifnull"
	Nullif = "nullif"

	// miscellaneous functions
	AnyValue        = "any_value"
	DefaultFunc     = "default_func"
	InetAton        = "inet_aton"
	InetNtoa        = "inet_ntoa"
	Inet6Aton       = "inet6_aton"
	Inet6Ntoa       = "inet6_ntoa"
	IsFreeLock      = "is_free_lock"
	IsIPv4          = "is_ipv4"
	IsIPv4Compat    = "is_ipv4_compat"
	IsIPv4Mapped    = "is_ipv4_mapped"
	IsIPv6          = "is_ipv6"
	IsUsedLock      = "is_used_lock"
	MasterPosWait   = "master_pos_wait"
	NameConst       = "name_const"
	ReleaseAllLocks = "release_all_locks"
	Sleep           = "sleep"
	UUID            = "uuid"
	UUIDShort       = "uuid_short"
	// get_lock() and release_lock() is parsed but do nothing.
	// It is used for preventing error in Ruby's activerecord migrations.
	GetLock     = "get_lock"
	ReleaseLock = "release_lock"

	// encryption and compression functions
	AesDecrypt               = "aes_decrypt"
	AesEncrypt               = "aes_encrypt"
	Compress                 = "compress"
	Decode                   = "decode"
	DesDecrypt               = "des_decrypt"
	DesEncrypt               = "des_encrypt"
	Encode                   = "encode"
	Encrypt                  = "encrypt"
	MD5                      = "md5"
	OldPassword              = "old_password"
	PasswordFunc             = "password_func"
	RandomBytes              = "random_bytes"
	SHA1                     = "sha1"
	SHA                      = "sha"
	SHA2                     = "sha2"
	Uncompress               = "uncompress"
	UncompressedLength       = "uncompressed_length"
	ValidatePasswordStrength = "validate_password_strength"

	// json functions
	JSONType     = "json_type"
	JSONExtract  = "json_extract"
	JSONUnquote  = "json_unquote"
	JSONArray    = "json_array"
	JSONObject   = "json_object"
	JSONMerge    = "json_merge"
	JSONValid    = "json_valid"
	JSONSet      = "json_set"
	JSONInsert   = "json_insert"
	JSONReplace  = "json_replace"
	JSONRemove   = "json_remove"
	JSONContains = "json_contains"
)

List scalar function names.

View Source
const (
	// AggFuncCount is the name of Count function.
	AggFuncCount = "count"
	// AggFuncSum is the name of Sum function.
	AggFuncSum = "sum"
	// AggFuncAvg is the name of Avg function.
	AggFuncAvg = "avg"
	// AggFuncFirstRow is the name of FirstRowColumn function.
	AggFuncFirstRow = "firstrow"
	// AggFuncMax is the name of max function.
	AggFuncMax = "max"
	// AggFuncMin is the name of min function.
	AggFuncMin = "min"
	// AggFuncGroupConcat is the name of group_concat function.
	AggFuncGroupConcat = "group_concat"
)
View Source
const (
	ReadCommitted   = "READ-COMMITTED"
	ReadUncommitted = "READ-UNCOMMITTED"
	Serializable    = "SERIALIZABLE"
	RepeatableRead  = "REPEATABLE-READ"
)

Isolation level constants.

View Source
const (
	AdminShowDDL = iota + 1
	AdminCheckTable
	AdminShowDDLJobs
)

Admin statement types.

View Source
const (
	// SetNames is the const for set names/charset stmt.
	// If VariableAssignment.Name == Names, it should be set names/charset stmt.
	SetNames = "SetNAMES"
)

Variables

This section is empty.

Functions

func HasAggFlag

func HasAggFlag(expr ExprNode) bool

HasAggFlag checks if the expr contains FlagHasAggregateFunc.

func SetFlag

func SetFlag(n Node)

SetFlag sets flag for expression.

Types

type AdminStmt

type AdminStmt struct {
	Tp     AdminStmtType
	Tables []*TableName
	// contains filtered or unexported fields
}

AdminStmt is the struct for Admin statement.

func (*AdminStmt) Accept

func (n *AdminStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accpet interface.

type AdminStmtType

type AdminStmtType int

AdminStmtType is the type for admin statement.

type AggregateFuncExpr

type AggregateFuncExpr struct {

	// F is the function name.
	F string
	// Args is the function args.
	Args []ExprNode
	// Distinct is true, function hence only aggregate distinct values.
	// For example, column c1 values are "1", "2", "2",  "sum(c1)" is "5",
	// but "sum(distinct c1)" is "3".
	Distinct bool
	// contains filtered or unexported fields
}

AggregateFuncExpr represents aggregate function expression.

func (*AggregateFuncExpr) Accept

func (n *AggregateFuncExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type AlterTableSpec

type AlterTableSpec struct {
	Tp            AlterTableType
	Name          string
	Constraint    *Constraint
	Options       []*TableOption
	NewTable      *TableName
	NewColumn     *ColumnDef
	OldColumnName *ColumnName
	Position      *ColumnPosition
	LockType      LockType
	// contains filtered or unexported fields
}

AlterTableSpec represents alter table specification.

func (*AlterTableSpec) Accept

func (n *AlterTableSpec) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*AlterTableSpec) SetText

func (n *AlterTableSpec) SetText(text string)

SetText implements Node interface.

func (*AlterTableSpec) Text

func (n *AlterTableSpec) Text() string

Text implements Node interface.

type AlterTableStmt

type AlterTableStmt struct {
	Table *TableName
	Specs []*AlterTableSpec
	// contains filtered or unexported fields
}

AlterTableStmt is a statement to change the structure of a table. See https://dev.mysql.com/doc/refman/5.7/en/alter-table.html

func (*AlterTableStmt) Accept

func (n *AlterTableStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type AlterTableType

type AlterTableType int

AlterTableType is the type for AlterTableSpec.

const (
	AlterTableOption AlterTableType = iota + 1
	AlterTableAddColumn
	AlterTableAddConstraint
	AlterTableDropColumn
	AlterTableDropPrimaryKey
	AlterTableDropIndex
	AlterTableDropForeignKey
	AlterTableModifyColumn
	AlterTableChangeColumn
	AlterTableRenameTable
	AlterTableAlterColumn
	AlterTableLock
)

AlterTable types.

type AlterUserStmt

type AlterUserStmt struct {
	IfExists    bool
	CurrentAuth *AuthOption
	Specs       []*UserSpec
	// contains filtered or unexported fields
}

AlterUserStmt modifies user account. See https://dev.mysql.com/doc/refman/5.7/en/alter-user.html

func (*AlterUserStmt) Accept

func (n *AlterUserStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*AlterUserStmt) SecureText

func (n *AlterUserStmt) SecureText() string

SecureText implements SensitiveStatement interface.

type AnalyzeTableStmt

type AnalyzeTableStmt struct {
	TableNames []*TableName
	IndexNames []model.CIStr
	// contains filtered or unexported fields
}

AnalyzeTableStmt is used to create table statistics.

func (*AnalyzeTableStmt) Accept

func (n *AnalyzeTableStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type Assignment

type Assignment struct {

	// Column is the column name to be assigned.
	Column *ColumnName
	// Expr is the expression assigning to ColName.
	Expr ExprNode
	// contains filtered or unexported fields
}

Assignment is the expression for assignment, like a = 1.

func (*Assignment) Accept

func (n *Assignment) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*Assignment) SetText

func (n *Assignment) SetText(text string)

SetText implements Node interface.

func (*Assignment) Text

func (n *Assignment) Text() string

Text implements Node interface.

type AuthOption

type AuthOption struct {
	// ByAuthString set as true, if AuthString is used for authorization. Otherwise, authorization is done by HashString.
	ByAuthString bool
	AuthString   string
	HashString   string
}

AuthOption is used for parsing create use statement.

type BeginStmt

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

BeginStmt is a statement to start a new transaction. See https://dev.mysql.com/doc/refman/5.7/en/commit.html

func (*BeginStmt) Accept

func (n *BeginStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type BetweenExpr

type BetweenExpr struct {

	// Expr is the expression to be checked.
	Expr ExprNode
	// Left is the expression for minimal value in the range.
	Left ExprNode
	// Right is the expression for maximum value in the range.
	Right ExprNode
	// Not is true, the expression is "not between and".
	Not bool
	// contains filtered or unexported fields
}

BetweenExpr is for "between and" or "not between and" expression.

func (*BetweenExpr) Accept

func (n *BetweenExpr) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

func (*BetweenExpr) GetDatum

func (en *BetweenExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*BetweenExpr) GetFlag

func (en *BetweenExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*BetweenExpr) GetType

func (en *BetweenExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*BetweenExpr) SetDatum

func (en *BetweenExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*BetweenExpr) SetFlag

func (en *BetweenExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*BetweenExpr) SetType

func (en *BetweenExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type BinaryOperationExpr

type BinaryOperationExpr struct {

	// Op is the operator code for BinaryOperation.
	Op opcode.Op
	// L is the left expression in BinaryOperation.
	L ExprNode
	// R is the right expression in BinaryOperation.
	R ExprNode
	// contains filtered or unexported fields
}

BinaryOperationExpr is for binary operation like `1 + 1`, `1 - 1`, etc.

func (*BinaryOperationExpr) Accept

func (n *BinaryOperationExpr) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

func (*BinaryOperationExpr) GetDatum

func (en *BinaryOperationExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*BinaryOperationExpr) GetFlag

func (en *BinaryOperationExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*BinaryOperationExpr) GetType

func (en *BinaryOperationExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*BinaryOperationExpr) SetDatum

func (en *BinaryOperationExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*BinaryOperationExpr) SetFlag

func (en *BinaryOperationExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*BinaryOperationExpr) SetType

func (en *BinaryOperationExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type BinlogStmt

type BinlogStmt struct {
	Str string
	// contains filtered or unexported fields
}

BinlogStmt is an internal-use statement. We just parse and ignore it. See http://dev.mysql.com/doc/refman/5.7/en/binlog.html

func (*BinlogStmt) Accept

func (n *BinlogStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type ByItem

type ByItem struct {
	Expr ExprNode
	Desc bool
	// contains filtered or unexported fields
}

ByItem represents an item in order by or group by.

func (*ByItem) Accept

func (n *ByItem) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ByItem) SetText

func (n *ByItem) SetText(text string)

SetText implements Node interface.

func (*ByItem) Text

func (n *ByItem) Text() string

Text implements Node interface.

type CaseExpr

type CaseExpr struct {

	// Value is the compare value expression.
	Value ExprNode
	// WhenClauses is the condition check expression.
	WhenClauses []*WhenClause
	// ElseClause is the else result expression.
	ElseClause ExprNode
	// contains filtered or unexported fields
}

CaseExpr is the case expression.

func (*CaseExpr) Accept

func (n *CaseExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*CaseExpr) GetDatum

func (en *CaseExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*CaseExpr) GetFlag

func (en *CaseExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*CaseExpr) GetType

func (en *CaseExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*CaseExpr) SetDatum

func (en *CaseExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*CaseExpr) SetFlag

func (en *CaseExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*CaseExpr) SetType

func (en *CaseExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type CastFunctionType

type CastFunctionType int

CastFunctionType is the type for cast function.

const (
	CastFunction CastFunctionType = iota + 1
	CastConvertFunction
	CastBinaryOperator
)

CastFunction types

type CharsetOpt

type CharsetOpt struct {
	Chs string
	Col string
}

CharsetOpt is used for parsing charset option from SQL.

type ColumnDef

type ColumnDef struct {
	Name    *ColumnName
	Tp      *types.FieldType
	Options []*ColumnOption
	// contains filtered or unexported fields
}

ColumnDef is used for parsing column definition from SQL.

func (*ColumnDef) Accept

func (n *ColumnDef) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ColumnDef) SetText

func (n *ColumnDef) SetText(text string)

SetText implements Node interface.

func (*ColumnDef) Text

func (n *ColumnDef) Text() string

Text implements Node interface.

type ColumnName

type ColumnName struct {
	Schema model.CIStr
	Table  model.CIStr
	Name   model.CIStr
	// contains filtered or unexported fields
}

ColumnName represents column name.

func (*ColumnName) Accept

func (n *ColumnName) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ColumnName) SetText

func (n *ColumnName) SetText(text string)

SetText implements Node interface.

func (*ColumnName) Text

func (n *ColumnName) Text() string

Text implements Node interface.

type ColumnNameExpr

type ColumnNameExpr struct {

	// Name is the referenced column name.
	Name *ColumnName

	// Refer is the result field the column name refers to.
	// The value of Refer.Expr is used as the value of the expression.
	Refer *ResultField
	// contains filtered or unexported fields
}

ColumnNameExpr represents a column name expression.

func (*ColumnNameExpr) Accept

func (n *ColumnNameExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ColumnNameExpr) GetDatum

func (en *ColumnNameExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*ColumnNameExpr) GetFlag

func (en *ColumnNameExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*ColumnNameExpr) GetType

func (en *ColumnNameExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*ColumnNameExpr) SetDatum

func (en *ColumnNameExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*ColumnNameExpr) SetFlag

func (en *ColumnNameExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*ColumnNameExpr) SetType

func (en *ColumnNameExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type ColumnOption

type ColumnOption struct {
	Tp ColumnOptionType
	// For ColumnOptionDefaultValue or ColumnOptionOnUpdate, it's the target value.
	// For ColumnOptionGenerated, it's the target expression.
	Expr ExprNode
	// Stored is only for ColumnOptionGenerated, default is false.
	Stored bool
	// contains filtered or unexported fields
}

ColumnOption is used for parsing column constraint info from SQL.

func (*ColumnOption) Accept

func (n *ColumnOption) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ColumnOption) SetText

func (n *ColumnOption) SetText(text string)

SetText implements Node interface.

func (*ColumnOption) Text

func (n *ColumnOption) Text() string

Text implements Node interface.

type ColumnOptionType

type ColumnOptionType int

ColumnOptionType is the type for ColumnOption.

const (
	ColumnOptionNoOption ColumnOptionType = iota
	ColumnOptionPrimaryKey
	ColumnOptionNotNull
	ColumnOptionAutoIncrement
	ColumnOptionDefaultValue
	ColumnOptionUniqKey
	ColumnOptionNull
	ColumnOptionOnUpdate // For Timestamp and Datetime only.
	ColumnOptionFulltext
	ColumnOptionComment
	ColumnOptionGenerated
)

ColumnOption types.

type ColumnPosition

type ColumnPosition struct {

	// Tp is either ColumnPositionNone, ColumnPositionFirst or ColumnPositionAfter.
	Tp ColumnPositionType
	// RelativeColumn is the column the newly added column after if type is ColumnPositionAfter
	RelativeColumn *ColumnName
	// contains filtered or unexported fields
}

ColumnPosition represent the position of the newly added column

func (*ColumnPosition) Accept

func (n *ColumnPosition) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ColumnPosition) SetText

func (n *ColumnPosition) SetText(text string)

SetText implements Node interface.

func (*ColumnPosition) Text

func (n *ColumnPosition) Text() string

Text implements Node interface.

type ColumnPositionType

type ColumnPositionType int

ColumnPositionType is the type for ColumnPosition.

const (
	ColumnPositionNone ColumnPositionType = iota
	ColumnPositionFirst
	ColumnPositionAfter
)

ColumnPosition Types

type CommitStmt

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

CommitStmt is a statement to commit the current transaction. See https://dev.mysql.com/doc/refman/5.7/en/commit.html

func (*CommitStmt) Accept

func (n *CommitStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type CompareSubqueryExpr

type CompareSubqueryExpr struct {

	// L is the left expression
	L ExprNode
	// Op is the comparison opcode.
	Op opcode.Op
	// R is the subquery for right expression, may be rewritten to other type of expression.
	R ExprNode
	// All is true, we should compare all records in subquery.
	All bool
	// contains filtered or unexported fields
}

CompareSubqueryExpr is the expression for "expr cmp (select ...)". See https://dev.mysql.com/doc/refman/5.7/en/comparisons-using-subqueries.html See https://dev.mysql.com/doc/refman/5.7/en/any-in-some-subqueries.html See https://dev.mysql.com/doc/refman/5.7/en/all-subqueries.html

func (*CompareSubqueryExpr) Accept

func (n *CompareSubqueryExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*CompareSubqueryExpr) GetDatum

func (en *CompareSubqueryExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*CompareSubqueryExpr) GetFlag

func (en *CompareSubqueryExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*CompareSubqueryExpr) GetType

func (en *CompareSubqueryExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*CompareSubqueryExpr) SetDatum

func (en *CompareSubqueryExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*CompareSubqueryExpr) SetFlag

func (en *CompareSubqueryExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*CompareSubqueryExpr) SetType

func (en *CompareSubqueryExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type Constraint

type Constraint struct {
	Tp   ConstraintType
	Name string

	Keys []*IndexColName // Used for PRIMARY KEY, UNIQUE, ......

	Refer *ReferenceDef // Used for foreign key.

	Option *IndexOption // Index Options
	// contains filtered or unexported fields
}

Constraint is constraint for table definition.

func (*Constraint) Accept

func (n *Constraint) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*Constraint) SetText

func (n *Constraint) SetText(text string)

SetText implements Node interface.

func (*Constraint) Text

func (n *Constraint) Text() string

Text implements Node interface.

type ConstraintType

type ConstraintType int

ConstraintType is the type for Constraint.

const (
	ConstraintNoConstraint ConstraintType = iota
	ConstraintPrimaryKey
	ConstraintKey
	ConstraintIndex
	ConstraintUniq
	ConstraintUniqKey
	ConstraintUniqIndex
	ConstraintForeignKey
	ConstraintFulltext
)

ConstraintTypes

type CreateDatabaseStmt

type CreateDatabaseStmt struct {
	IfNotExists bool
	Name        string
	Options     []*DatabaseOption
	// contains filtered or unexported fields
}

CreateDatabaseStmt is a statement to create a database. See https://dev.mysql.com/doc/refman/5.7/en/create-database.html

func (*CreateDatabaseStmt) Accept

func (n *CreateDatabaseStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type CreateIndexStmt

type CreateIndexStmt struct {
	IndexName     string
	Table         *TableName
	Unique        bool
	IndexColNames []*IndexColName
	IndexOption   *IndexOption
	// contains filtered or unexported fields
}

CreateIndexStmt is a statement to create an index. See https://dev.mysql.com/doc/refman/5.7/en/create-index.html

func (*CreateIndexStmt) Accept

func (n *CreateIndexStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type CreateTableStmt

type CreateTableStmt struct {
	IfNotExists bool
	Table       *TableName
	ReferTable  *TableName
	Cols        []*ColumnDef
	Constraints []*Constraint
	Options     []*TableOption
	// contains filtered or unexported fields
}

CreateTableStmt is a statement to create a table. See https://dev.mysql.com/doc/refman/5.7/en/create-table.html

func (*CreateTableStmt) Accept

func (n *CreateTableStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type CreateUserStmt

type CreateUserStmt struct {
	IfNotExists bool
	Specs       []*UserSpec
	// contains filtered or unexported fields
}

CreateUserStmt creates user account. See https://dev.mysql.com/doc/refman/5.7/en/create-user.html

func (*CreateUserStmt) Accept

func (n *CreateUserStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*CreateUserStmt) SecureText

func (n *CreateUserStmt) SecureText() string

SecureText implements SensitiveStatement interface.

type DDLNode

type DDLNode interface {
	StmtNode
	// contains filtered or unexported methods
}

DDLNode represents DDL statement node.

type DMLNode

type DMLNode interface {
	StmtNode
	// contains filtered or unexported methods
}

DMLNode represents DML statement node.

type DatabaseOption

type DatabaseOption struct {
	Tp    DatabaseOptionType
	Value string
}

DatabaseOption represents database option.

type DatabaseOptionType

type DatabaseOptionType int

DatabaseOptionType is the type for database options.

const (
	DatabaseOptionNone DatabaseOptionType = iota
	DatabaseOptionCharset
	DatabaseOptionCollate
)

Database option types.

type DateArithType

type DateArithType byte

DateArithType is type for DateArith type.

type DeallocateStmt

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

DeallocateStmt is a statement to release PreparedStmt. See https://dev.mysql.com/doc/refman/5.7/en/deallocate-prepare.html

func (*DeallocateStmt) Accept

func (n *DeallocateStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type DefaultExpr

type DefaultExpr struct {

	// Name is the column name.
	Name *ColumnName
	// contains filtered or unexported fields
}

DefaultExpr is the default expression using default value for a column.

func (*DefaultExpr) Accept

func (n *DefaultExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*DefaultExpr) GetDatum

func (en *DefaultExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*DefaultExpr) GetFlag

func (en *DefaultExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*DefaultExpr) GetType

func (en *DefaultExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*DefaultExpr) SetDatum

func (en *DefaultExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*DefaultExpr) SetFlag

func (en *DefaultExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*DefaultExpr) SetType

func (en *DefaultExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type DeleteStmt

type DeleteStmt struct {

	// TableRefs is used in both single table and multiple table delete statement.
	TableRefs *TableRefsClause
	// Tables is only used in multiple table delete statement.
	Tables       *DeleteTableList
	Where        ExprNode
	Order        *OrderByClause
	Limit        *Limit
	LowPriority  bool
	Ignore       bool
	Quick        bool
	IsMultiTable bool
	BeforeFrom   bool
	// contains filtered or unexported fields
}

DeleteStmt is a statement to delete rows from table. See https://dev.mysql.com/doc/refman/5.7/en/delete.html

func (*DeleteStmt) Accept

func (n *DeleteStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type DeleteTableList

type DeleteTableList struct {
	Tables []*TableName
	// contains filtered or unexported fields
}

DeleteTableList is the tablelist used in delete statement multi-table mode.

func (*DeleteTableList) Accept

func (n *DeleteTableList) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*DeleteTableList) SetText

func (n *DeleteTableList) SetText(text string)

SetText implements Node interface.

func (*DeleteTableList) Text

func (n *DeleteTableList) Text() string

Text implements Node interface.

type DoStmt

type DoStmt struct {
	Exprs []ExprNode
	// contains filtered or unexported fields
}

DoStmt is the struct for DO statement.

func (*DoStmt) Accept

func (n *DoStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type DropDatabaseStmt

type DropDatabaseStmt struct {
	IfExists bool
	Name     string
	// contains filtered or unexported fields
}

DropDatabaseStmt is a statement to drop a database and all tables in the database. See https://dev.mysql.com/doc/refman/5.7/en/drop-database.html

func (*DropDatabaseStmt) Accept

func (n *DropDatabaseStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type DropIndexStmt

type DropIndexStmt struct {
	IfExists  bool
	IndexName string
	Table     *TableName
	// contains filtered or unexported fields
}

DropIndexStmt is a statement to drop the index. See https://dev.mysql.com/doc/refman/5.7/en/drop-index.html

func (*DropIndexStmt) Accept

func (n *DropIndexStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type DropStatsStmt

type DropStatsStmt struct {
	Table *TableName
	// contains filtered or unexported fields
}

DropStatsStmt is used to drop table statistics.

func (*DropStatsStmt) Accept

func (n *DropStatsStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type DropTableStmt

type DropTableStmt struct {
	IfExists bool
	Tables   []*TableName
	// contains filtered or unexported fields
}

DropTableStmt is a statement to drop one or more tables. See https://dev.mysql.com/doc/refman/5.7/en/drop-table.html

func (*DropTableStmt) Accept

func (n *DropTableStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type DropUserStmt

type DropUserStmt struct {
	IfExists bool
	UserList []*auth.UserIdentity
	// contains filtered or unexported fields
}

DropUserStmt creates user account. See http://dev.mysql.com/doc/refman/5.7/en/drop-user.html

func (*DropUserStmt) Accept

func (n *DropUserStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type ExecuteStmt

type ExecuteStmt struct {
	Name      string
	UsingVars []ExprNode
	// contains filtered or unexported fields
}

ExecuteStmt is a statement to execute PreparedStmt. See https://dev.mysql.com/doc/refman/5.7/en/execute.html

func (*ExecuteStmt) Accept

func (n *ExecuteStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type ExistsSubqueryExpr

type ExistsSubqueryExpr struct {

	// Sel is the subquery, may be rewritten to other type of expression.
	Sel ExprNode
	// contains filtered or unexported fields
}

ExistsSubqueryExpr is the expression for "exists (select ...)". See https://dev.mysql.com/doc/refman/5.7/en/exists-and-not-exists-subqueries.html

func (*ExistsSubqueryExpr) Accept

func (n *ExistsSubqueryExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ExistsSubqueryExpr) GetDatum

func (en *ExistsSubqueryExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*ExistsSubqueryExpr) GetFlag

func (en *ExistsSubqueryExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*ExistsSubqueryExpr) GetType

func (en *ExistsSubqueryExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*ExistsSubqueryExpr) SetDatum

func (en *ExistsSubqueryExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*ExistsSubqueryExpr) SetFlag

func (en *ExistsSubqueryExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*ExistsSubqueryExpr) SetType

func (en *ExistsSubqueryExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type ExplainStmt

type ExplainStmt struct {
	Stmt StmtNode
	// contains filtered or unexported fields
}

ExplainStmt is a statement to provide information about how is SQL statement executed or get columns information in a table. See https://dev.mysql.com/doc/refman/5.7/en/explain.html

func (*ExplainStmt) Accept

func (n *ExplainStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type ExprNode

type ExprNode interface {
	// Node is embedded in ExprNode.
	Node
	// SetType sets evaluation type to the expression.
	SetType(tp *types.FieldType)
	// GetType gets the evaluation type of the expression.
	GetType() *types.FieldType
	// SetValue sets value to the expression.
	SetValue(val interface{})
	// GetValue gets value of the expression.
	GetValue() interface{}
	// SetDatum sets datum to the expression.
	SetDatum(datum types.Datum)
	// GetDatum gets datum of the expression.
	GetDatum() *types.Datum
	// SetFlag sets flag to the expression.
	// Flag indicates whether the expression contains
	// parameter marker, reference, aggregate function...
	SetFlag(flag uint64)
	// GetFlag returns the flag of the expression.
	GetFlag() uint64
}

ExprNode is a node that can be evaluated. Name of implementations should have 'Expr' suffix.

type FieldList

type FieldList struct {
	Fields []*SelectField
	// contains filtered or unexported fields
}

FieldList represents field list in select statement.

func (*FieldList) Accept

func (n *FieldList) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*FieldList) SetText

func (n *FieldList) SetText(text string)

SetText implements Node interface.

func (*FieldList) Text

func (n *FieldList) Text() string

Text implements Node interface.

type FieldsClause

type FieldsClause struct {
	Terminated string
	Enclosed   byte
	Escaped    byte
}

FieldsClause represents fields references clause in load data statement.

type FloatOpt

type FloatOpt struct {
	Flen    int
	Decimal int
}

FloatOpt is used for parsing floating-point type option from SQL. See http://dev.mysql.com/doc/refman/5.7/en/floating-point-types.html

type FlushStmt

type FlushStmt struct {
	Tp              FlushStmtType // Privileges/Tables/...
	NoWriteToBinLog bool
	Tables          []*TableName // For FlushTableStmt, if Tables is empty, it means flush all tables.
	ReadLock        bool
	// contains filtered or unexported fields
}

FlushStmt is a statement to flush tables/privileges/optimizer costs and so on.

func (*FlushStmt) Accept

func (n *FlushStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type FlushStmtType

type FlushStmtType int

FlushStmtType is the type for FLUSH statement.

const (
	FlushNone FlushStmtType = iota
	FlushTables
	FlushPrivileges
)

Flush statement types.

type FuncCallExpr

type FuncCallExpr struct {

	// FnName is the function name.
	FnName model.CIStr
	// Args is the function args.
	Args []ExprNode
	// contains filtered or unexported fields
}

FuncCallExpr is for function expression.

func (*FuncCallExpr) Accept

func (n *FuncCallExpr) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

type FuncCastExpr

type FuncCastExpr struct {

	// Expr is the expression to be converted.
	Expr ExprNode
	// Tp is the conversion type.
	Tp *types.FieldType
	// FunctionType is either Cast, Convert or Binary.
	FunctionType CastFunctionType
	// contains filtered or unexported fields
}

FuncCastExpr is the cast function converting value to another type, e.g, cast(expr AS signed). See https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html

func (*FuncCastExpr) Accept

func (n *FuncCastExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type FuncNode

type FuncNode interface {
	ExprNode
	// contains filtered or unexported methods
}

FuncNode represents function call expression node.

type GrantLevel

type GrantLevel struct {
	Level     GrantLevelType
	DBName    string
	TableName string
}

GrantLevel is used for store the privilege scope.

type GrantLevelType

type GrantLevelType int

GrantLevelType is the type for grant level.

const (
	// GrantLevelNone is the dummy const for default value.
	GrantLevelNone GrantLevelType = iota + 1
	// GrantLevelGlobal means the privileges are administrative or apply to all databases on a given server.
	GrantLevelGlobal
	// GrantLevelDB means the privileges apply to all objects in a given database.
	GrantLevelDB
	// GrantLevelTable means the privileges apply to all columns in a given table.
	GrantLevelTable
)

type GrantStmt

type GrantStmt struct {
	Privs      []*PrivElem
	ObjectType ObjectTypeType
	Level      *GrantLevel
	Users      []*UserSpec
	WithGrant  bool
	// contains filtered or unexported fields
}

GrantStmt is the struct for GRANT statement.

func (*GrantStmt) Accept

func (n *GrantStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*GrantStmt) SecureText

func (n *GrantStmt) SecureText() string

SecureText implements SensitiveStatement interface.

type GroupByClause

type GroupByClause struct {
	Items []*ByItem
	// contains filtered or unexported fields
}

GroupByClause represents group by clause.

func (*GroupByClause) Accept

func (n *GroupByClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*GroupByClause) SetText

func (n *GroupByClause) SetText(text string)

SetText implements Node interface.

func (*GroupByClause) Text

func (n *GroupByClause) Text() string

Text implements Node interface.

type HavingClause

type HavingClause struct {
	Expr ExprNode
	// contains filtered or unexported fields
}

HavingClause represents having clause.

func (*HavingClause) Accept

func (n *HavingClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*HavingClause) SetText

func (n *HavingClause) SetText(text string)

SetText implements Node interface.

func (*HavingClause) Text

func (n *HavingClause) Text() string

Text implements Node interface.

type Ident

type Ident struct {
	Schema model.CIStr
	Name   model.CIStr
}

Ident is the table identifier composed of schema name and table name.

func (Ident) Full

func (i Ident) Full(ctx context.Context) (full Ident)

Full returns an Ident which set schema to the current schema if it is empty.

func (Ident) String

func (i Ident) String() string

String implements fmt.Stringer interface.

type IndexColName

type IndexColName struct {
	Column *ColumnName
	Length int
	// contains filtered or unexported fields
}

IndexColName is used for parsing index column name from SQL.

func (*IndexColName) Accept

func (n *IndexColName) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*IndexColName) SetText

func (n *IndexColName) SetText(text string)

SetText implements Node interface.

func (*IndexColName) Text

func (n *IndexColName) Text() string

Text implements Node interface.

type IndexHint

type IndexHint struct {
	IndexNames []model.CIStr
	HintType   IndexHintType
	HintScope  IndexHintScope
}

IndexHint represents a hint for optimizer to use/ignore/force for join/order by/group by.

type IndexHintScope

type IndexHintScope int

IndexHintScope is the type for index hint for join, order by or group by.

const (
	HintForScan    IndexHintScope = 1
	HintForJoin    IndexHintScope = 2
	HintForOrderBy IndexHintScope = 3
	HintForGroupBy IndexHintScope = 4
)

Index hint scopes.

type IndexHintType

type IndexHintType int

IndexHintType is the type for index hint use, ignore or force.

const (
	HintUse    IndexHintType = 1
	HintIgnore IndexHintType = 2
	HintForce  IndexHintType = 3
)

IndexHintUseType values.

type IndexOption

type IndexOption struct {
	KeyBlockSize uint64
	Tp           model.IndexType
	Comment      string
	// contains filtered or unexported fields
}

IndexOption is the index options.

  KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'

See http://dev.mysql.com/doc/refman/5.7/en/create-table.html

func (*IndexOption) Accept

func (n *IndexOption) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*IndexOption) SetText

func (n *IndexOption) SetText(text string)

SetText implements Node interface.

func (*IndexOption) Text

func (n *IndexOption) Text() string

Text implements Node interface.

type InsertStmt

type InsertStmt struct {
	IsReplace   bool
	IgnoreErr   bool
	Table       *TableRefsClause
	Columns     []*ColumnName
	Lists       [][]ExprNode
	Setlist     []*Assignment
	Priority    mysql.PriorityEnum
	OnDuplicate []*Assignment
	Select      ResultSetNode
	// contains filtered or unexported fields
}

InsertStmt is a statement to insert new rows into an existing table. See https://dev.mysql.com/doc/refman/5.7/en/insert.html

func (*InsertStmt) Accept

func (n *InsertStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type IsNullExpr

type IsNullExpr struct {

	// Expr is the expression to be checked.
	Expr ExprNode
	// Not is true, the expression is "is not null".
	Not bool
	// contains filtered or unexported fields
}

IsNullExpr is the expression for null check.

func (*IsNullExpr) Accept

func (n *IsNullExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*IsNullExpr) GetDatum

func (en *IsNullExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*IsNullExpr) GetFlag

func (en *IsNullExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*IsNullExpr) GetType

func (en *IsNullExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*IsNullExpr) SetDatum

func (en *IsNullExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*IsNullExpr) SetFlag

func (en *IsNullExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*IsNullExpr) SetType

func (en *IsNullExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type IsTruthExpr

type IsTruthExpr struct {

	// Expr is the expression to be checked.
	Expr ExprNode
	// Not is true, the expression is "is not true/false".
	Not bool
	// True indicates checking true or false.
	True int64
	// contains filtered or unexported fields
}

IsTruthExpr is the expression for true/false check.

func (*IsTruthExpr) Accept

func (n *IsTruthExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*IsTruthExpr) GetDatum

func (en *IsTruthExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*IsTruthExpr) GetFlag

func (en *IsTruthExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*IsTruthExpr) GetType

func (en *IsTruthExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*IsTruthExpr) SetDatum

func (en *IsTruthExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*IsTruthExpr) SetFlag

func (en *IsTruthExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*IsTruthExpr) SetType

func (en *IsTruthExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type Join

type Join struct {

	// Left table can be TableSource or JoinNode.
	Left ResultSetNode
	// Right table can be TableSource or JoinNode or nil.
	Right ResultSetNode
	// Tp represents join type.
	Tp JoinType
	// On represents join on condition.
	On *OnCondition
	// Using represents join using clause.
	Using []*ColumnName
	// NaturalJoin represents join is natural join
	NaturalJoin bool
	// contains filtered or unexported fields
}

Join represents table join.

func (*Join) Accept

func (n *Join) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*Join) GetResultFields

func (rs *Join) GetResultFields() []*ResultField

GetResultFields implements ResultSetNode interface.

func (*Join) SetResultFields

func (rs *Join) SetResultFields(rfs []*ResultField)

SetResultFields implements ResultSetNode interface.

func (*Join) SetText

func (n *Join) SetText(text string)

SetText implements Node interface.

func (*Join) Text

func (n *Join) Text() string

Text implements Node interface.

type JoinType

type JoinType int

JoinType is join type, including cross/left/right/full.

const (
	// CrossJoin is cross join type.
	CrossJoin JoinType = iota + 1
	// LeftJoin is left Join type.
	LeftJoin
	// RightJoin is right Join type.
	RightJoin
)

type KillStmt

type KillStmt struct {

	// Query indicates whether terminate a single query on this connection or the whole connection.
	// If Query is true, terminates the statement the connection is currently executing, but leaves the connection itself intact.
	// If Query is false, terminates the connection associated with the given ConnectionID, after terminating any statement the connection is executing.
	Query        bool
	ConnectionID uint64
	// TiDBExtension is used to indicate whether the user knows he is sending kill statement to the right tidb-server.
	// When the SQL grammar is "KILL TIDB [CONNECTION | QUERY] connectionID", TiDBExtension will be set.
	// It's a special grammar extension in TiDB. This extension exists because, when the connection is:
	// client -> LVS proxy -> TiDB, and type Ctrl+C in client, the following action will be executed:
	// new a connection; kill xxx;
	// kill command may send to the wrong TiDB, because the exists of LVS proxy, and kill the wrong session.
	// So, "KILL TIDB" grammar is introduced, and it REQUIRES DIRECT client -> TiDB TOPOLOGY.
	// TODO: The standard KILL grammar will be supported once we have global connectionID.
	TiDBExtension bool
	// contains filtered or unexported fields
}

KillStmt is a statement to kill a query or connection.

func (*KillStmt) Accept

func (n *KillStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type Limit

type Limit struct {
	Count  ExprNode
	Offset ExprNode
	// contains filtered or unexported fields
}

Limit is the limit clause.

func (*Limit) Accept

func (n *Limit) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*Limit) SetText

func (n *Limit) SetText(text string)

SetText implements Node interface.

func (*Limit) Text

func (n *Limit) Text() string

Text implements Node interface.

type LinesClause

type LinesClause struct {
	Starting   string
	Terminated string
}

LinesClause represents lines references clause in load data statement.

type LoadDataStmt

type LoadDataStmt struct {
	IsLocal    bool
	Path       string
	Table      *TableName
	Columns    []*ColumnName
	FieldsInfo *FieldsClause
	LinesInfo  *LinesClause
	// contains filtered or unexported fields
}

LoadDataStmt is a statement to load data from a specified file, then insert this rows into an existing table. See https://dev.mysql.com/doc/refman/5.7/en/load-data.html

func (*LoadDataStmt) Accept

func (n *LoadDataStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type LockType

type LockType byte

LockType is the type for AlterTableSpec. See https://dev.mysql.com/doc/refman/5.7/en/alter-table.html#alter-table-concurrency

const (
	LockTypeNone LockType = iota + 1
	LockTypeDefault
	LockTypeShared
	LockTypeExclusive
)

Lock Types.

type Node

type Node interface {
	// Accept accepts Visitor to visit itself.
	// The returned node should replace original node.
	// ok returns false to stop visiting.
	//
	// Implementation of this method should first call visitor.Enter,
	// assign the returned node to its method receiver, if skipChildren returns true,
	// children should be skipped. Otherwise, call its children in particular order that
	// later elements depends on former elements. Finally, return visitor.Leave.
	Accept(v Visitor) (node Node, ok bool)
	// Text returns the original text of the element.
	Text() string
	// SetText sets original text to the Node.
	SetText(text string)
}

Node is the basic element of the AST. Interfaces embed Node should have 'Node' name suffix.

type ObjectTypeType

type ObjectTypeType int

ObjectTypeType is the type for object type.

const (
	// ObjectTypeNone is for empty object type.
	ObjectTypeNone ObjectTypeType = iota + 1
	// ObjectTypeTable means the following object is a table.
	ObjectTypeTable
)

type OnCondition

type OnCondition struct {
	Expr ExprNode
	// contains filtered or unexported fields
}

OnCondition represetns JOIN on condition.

func (*OnCondition) Accept

func (n *OnCondition) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*OnCondition) SetText

func (n *OnCondition) SetText(text string)

SetText implements Node interface.

func (*OnCondition) Text

func (n *OnCondition) Text() string

Text implements Node interface.

type OnDeleteOpt

type OnDeleteOpt struct {
	ReferOpt ReferOptionType
	// contains filtered or unexported fields
}

OnDeleteOpt is used for optional on delete clause.

func (*OnDeleteOpt) Accept

func (n *OnDeleteOpt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*OnDeleteOpt) SetText

func (n *OnDeleteOpt) SetText(text string)

SetText implements Node interface.

func (*OnDeleteOpt) Text

func (n *OnDeleteOpt) Text() string

Text implements Node interface.

type OnUpdateOpt

type OnUpdateOpt struct {
	ReferOpt ReferOptionType
	// contains filtered or unexported fields
}

OnUpdateOpt is used for optional on update clause.

func (*OnUpdateOpt) Accept

func (n *OnUpdateOpt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*OnUpdateOpt) SetText

func (n *OnUpdateOpt) SetText(text string)

SetText implements Node interface.

func (*OnUpdateOpt) Text

func (n *OnUpdateOpt) Text() string

Text implements Node interface.

type OrderByClause

type OrderByClause struct {
	Items    []*ByItem
	ForUnion bool
	// contains filtered or unexported fields
}

OrderByClause represents order by clause.

func (*OrderByClause) Accept

func (n *OrderByClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*OrderByClause) SetText

func (n *OrderByClause) SetText(text string)

SetText implements Node interface.

func (*OrderByClause) Text

func (n *OrderByClause) Text() string

Text implements Node interface.

type ParamMarkerExpr

type ParamMarkerExpr struct {
	Offset int
	// contains filtered or unexported fields
}

ParamMarkerExpr expression holds a place for another expression. Used in parsing prepare statement.

func (*ParamMarkerExpr) Accept

func (n *ParamMarkerExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ParamMarkerExpr) GetDatum

func (en *ParamMarkerExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*ParamMarkerExpr) GetFlag

func (en *ParamMarkerExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*ParamMarkerExpr) GetType

func (en *ParamMarkerExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*ParamMarkerExpr) SetDatum

func (en *ParamMarkerExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*ParamMarkerExpr) SetFlag

func (en *ParamMarkerExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*ParamMarkerExpr) SetType

func (en *ParamMarkerExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type ParenthesesExpr

type ParenthesesExpr struct {

	// Expr is the expression in parentheses.
	Expr ExprNode
	// contains filtered or unexported fields
}

ParenthesesExpr is the parentheses expression.

func (*ParenthesesExpr) Accept

func (n *ParenthesesExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ParenthesesExpr) GetDatum

func (en *ParenthesesExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*ParenthesesExpr) GetFlag

func (en *ParenthesesExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*ParenthesesExpr) GetType

func (en *ParenthesesExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*ParenthesesExpr) SetDatum

func (en *ParenthesesExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*ParenthesesExpr) SetFlag

func (en *ParenthesesExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*ParenthesesExpr) SetType

func (en *ParenthesesExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type PatternInExpr

type PatternInExpr struct {

	// Expr is the value expression to be compared.
	Expr ExprNode
	// List is the list expression in compare list.
	List []ExprNode
	// Not is true, the expression is "not in".
	Not bool
	// Sel is the subquery, may be rewritten to other type of expression.
	Sel ExprNode
	// contains filtered or unexported fields
}

PatternInExpr is the expression for in operator, like "expr in (1, 2, 3)" or "expr in (select c from t)".

func (*PatternInExpr) Accept

func (n *PatternInExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*PatternInExpr) GetDatum

func (en *PatternInExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*PatternInExpr) GetFlag

func (en *PatternInExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*PatternInExpr) GetType

func (en *PatternInExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*PatternInExpr) SetDatum

func (en *PatternInExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*PatternInExpr) SetFlag

func (en *PatternInExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*PatternInExpr) SetType

func (en *PatternInExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type PatternLikeExpr

type PatternLikeExpr struct {

	// Expr is the expression to be checked.
	Expr ExprNode
	// Pattern is the like expression.
	Pattern ExprNode
	// Not is true, the expression is "not like".
	Not bool

	Escape byte

	PatChars []byte
	PatTypes []byte
	// contains filtered or unexported fields
}

PatternLikeExpr is the expression for like operator, e.g, expr like "%123%"

func (*PatternLikeExpr) Accept

func (n *PatternLikeExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*PatternLikeExpr) GetDatum

func (en *PatternLikeExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*PatternLikeExpr) GetFlag

func (en *PatternLikeExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*PatternLikeExpr) GetType

func (en *PatternLikeExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*PatternLikeExpr) SetDatum

func (en *PatternLikeExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*PatternLikeExpr) SetFlag

func (en *PatternLikeExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*PatternLikeExpr) SetType

func (en *PatternLikeExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type PatternRegexpExpr

type PatternRegexpExpr struct {

	// Expr is the expression to be checked.
	Expr ExprNode
	// Pattern is the expression for pattern.
	Pattern ExprNode
	// Not is true, the expression is "not rlike",
	Not bool

	// Re is the compiled regexp.
	Re *regexp.Regexp
	// Sexpr is the string for Expr expression.
	Sexpr *string
	// contains filtered or unexported fields
}

PatternRegexpExpr is the pattern expression for pattern match.

func (*PatternRegexpExpr) Accept

func (n *PatternRegexpExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*PatternRegexpExpr) GetDatum

func (en *PatternRegexpExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*PatternRegexpExpr) GetFlag

func (en *PatternRegexpExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*PatternRegexpExpr) GetType

func (en *PatternRegexpExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*PatternRegexpExpr) SetDatum

func (en *PatternRegexpExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*PatternRegexpExpr) SetFlag

func (en *PatternRegexpExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*PatternRegexpExpr) SetType

func (en *PatternRegexpExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type PositionExpr

type PositionExpr struct {

	// N is the position, started from 1 now.
	N int
	// Refer is the result field the position refers to.
	Refer *ResultField
	// contains filtered or unexported fields
}

PositionExpr is the expression for order by and group by position. MySQL use position expression started from 1, it looks a little confused inner. maybe later we will use 0 at first.

func (*PositionExpr) Accept

func (n *PositionExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*PositionExpr) GetDatum

func (en *PositionExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*PositionExpr) GetFlag

func (en *PositionExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*PositionExpr) GetType

func (en *PositionExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*PositionExpr) SetDatum

func (en *PositionExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*PositionExpr) SetFlag

func (en *PositionExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*PositionExpr) SetType

func (en *PositionExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type PrepareStmt

type PrepareStmt struct {
	Name    string
	SQLText string
	SQLVar  *VariableExpr
	// contains filtered or unexported fields
}

PrepareStmt is a statement to prepares a SQL statement which contains placeholders, and it is executed with ExecuteStmt and released with DeallocateStmt. See https://dev.mysql.com/doc/refman/5.7/en/prepare.html

func (*PrepareStmt) Accept

func (n *PrepareStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type PrivElem

type PrivElem struct {
	Priv mysql.PrivilegeType
	Cols []*ColumnName
	// contains filtered or unexported fields
}

PrivElem is the privilege type and optional column list.

func (*PrivElem) Accept

func (n *PrivElem) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*PrivElem) SetText

func (n *PrivElem) SetText(text string)

SetText implements Node interface.

func (*PrivElem) Text

func (n *PrivElem) Text() string

Text implements Node interface.

type RecordSet

type RecordSet interface {

	// Fields gets result fields.
	Fields() (fields []*ResultField, err error)

	// Next returns the next row, nil row means there is no more to return.
	Next() (row *Row, err error)

	// Close closes the underlying iterator, call Next after Close will
	// restart the iteration.
	Close() error
}

RecordSet is an abstract result set interface to help get data from Plan.

type ReferOptionType

type ReferOptionType int

ReferOptionType is the type for refer options.

const (
	ReferOptionNoOption ReferOptionType = iota
	ReferOptionRestrict
	ReferOptionCascade
	ReferOptionSetNull
	ReferOptionNoAction
)

Refer option types.

func (ReferOptionType) String

func (r ReferOptionType) String() string

String implements fmt.Stringer interface.

type ReferenceDef

type ReferenceDef struct {
	Table         *TableName
	IndexColNames []*IndexColName
	OnDelete      *OnDeleteOpt
	OnUpdate      *OnUpdateOpt
	// contains filtered or unexported fields
}

ReferenceDef is used for parsing foreign key reference option from SQL. See http://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html

func (*ReferenceDef) Accept

func (n *ReferenceDef) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ReferenceDef) SetText

func (n *ReferenceDef) SetText(text string)

SetText implements Node interface.

func (*ReferenceDef) Text

func (n *ReferenceDef) Text() string

Text implements Node interface.

type RenameTableStmt

type RenameTableStmt struct {
	OldTable *TableName
	NewTable *TableName
	// TODO: Refactor this when you are going to add full support for multiple schema changes.
	// Currently it is only useful for syncer which depends heavily on tidb parser to do some dirty work.
	TableToTables []*TableToTable
	// contains filtered or unexported fields
}

RenameTableStmt is a statement to rename a table. See http://dev.mysql.com/doc/refman/5.7/en/rename-table.html

func (*RenameTableStmt) Accept

func (n *RenameTableStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type ResultField

type ResultField struct {
	Column       *model.ColumnInfo
	ColumnAsName model.CIStr
	Table        *model.TableInfo
	TableAsName  model.CIStr
	DBName       model.CIStr

	// Expr represents the expression for the result field. If it is generated from a select field, it would
	// be the expression of that select field, otherwise the type would be ValueExpr and value
	// will be set for every retrieved row.
	Expr      ExprNode
	TableName *TableName
	// Referenced indicates the result field has been referenced or not.
	// If not, we don't need to get the values.
	Referenced bool
}

ResultField represents a result field which can be a column from a table, or an expression in select field. It is a generated property during binding process. ResultField is the key element to evaluate a ColumnNameExpr. After resolving process, every ColumnNameExpr will be resolved to a ResultField. During execution, every row retrieved from table will set the row value to ResultFields of that table, so ColumnNameExpr resolved to that ResultField can be easily evaluated.

type ResultSetNode

type ResultSetNode interface {
	Node
	// GetResultFields gets result fields.
	GetResultFields() []*ResultField
	// SetResultFields sets result fields.
	SetResultFields(fields []*ResultField)
}

ResultSetNode interface has a ResultFields property, represents a Node that returns result set. Implementations include SelectStmt, SubqueryExpr, TableSource, TableName and Join.

type RevokeStmt

type RevokeStmt struct {
	Privs      []*PrivElem
	ObjectType ObjectTypeType
	Level      *GrantLevel
	Users      []*UserSpec
	// contains filtered or unexported fields
}

RevokeStmt is the struct for REVOKE statement.

func (*RevokeStmt) Accept

func (n *RevokeStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type RollbackStmt

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

RollbackStmt is a statement to roll back the current transaction. See https://dev.mysql.com/doc/refman/5.7/en/commit.html

func (*RollbackStmt) Accept

func (n *RollbackStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type Row

type Row struct {
	Data []types.Datum
}

Row represents a single row from Recordset.

type RowExpr

type RowExpr struct {
	Values []ExprNode
	// contains filtered or unexported fields
}

RowExpr is the expression for row constructor. See https://dev.mysql.com/doc/refman/5.7/en/row-subqueries.html

func (*RowExpr) Accept

func (n *RowExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*RowExpr) GetDatum

func (en *RowExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*RowExpr) GetFlag

func (en *RowExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*RowExpr) GetType

func (en *RowExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*RowExpr) SetDatum

func (en *RowExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*RowExpr) SetFlag

func (en *RowExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*RowExpr) SetType

func (en *RowExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type SelectField

type SelectField struct {

	// Offset is used to get original text.
	Offset int
	// WildCard is not nil, Expr will be nil.
	WildCard *WildCardField
	// Expr is not nil, WildCard will be nil.
	Expr ExprNode
	// AsName is alias name for Expr.
	AsName model.CIStr
	// Auxiliary stands for if this field is auxiliary.
	// When we add a Field into SelectField list which is used for having/orderby clause but the field is not in select clause,
	// we should set its Auxiliary to true. Then the TrimExec will trim the field.
	Auxiliary bool
	// contains filtered or unexported fields
}

SelectField represents fields in select statement. There are two type of select field: wildcard and expression with optional alias name.

func (*SelectField) Accept

func (n *SelectField) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*SelectField) SetText

func (n *SelectField) SetText(text string)

SetText implements Node interface.

func (*SelectField) Text

func (n *SelectField) Text() string

Text implements Node interface.

type SelectLockType

type SelectLockType int

SelectLockType is the lock type for SelectStmt.

const (
	SelectLockNone SelectLockType = iota
	SelectLockForUpdate
	SelectLockInShareMode
)

Select lock types.

func (SelectLockType) String

func (slt SelectLockType) String() string

String implements fmt.Stringer.

type SelectStmt

type SelectStmt struct {

	// SelectStmtOpts wraps around select hints and switches.
	*SelectStmtOpts
	// Distinct represents whether the select has distinct option.
	Distinct bool
	// From is the from clause of the query.
	From *TableRefsClause
	// Where is the where clause in select statement.
	Where ExprNode
	// Fields is the select expression list.
	Fields *FieldList
	// GroupBy is the group by expression list.
	GroupBy *GroupByClause
	// Having is the having condition.
	Having *HavingClause
	// OrderBy is the ordering expression list.
	OrderBy *OrderByClause
	// Limit is the limit clause.
	Limit *Limit
	// LockTp is the lock type
	LockTp SelectLockType
	// TableHints represents the level Optimizer Hint
	TableHints []*TableOptimizerHint
	// contains filtered or unexported fields
}

SelectStmt represents the select query node. See https://dev.mysql.com/doc/refman/5.7/en/select.html

func (*SelectStmt) Accept

func (n *SelectStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*SelectStmt) GetResultFields

func (rs *SelectStmt) GetResultFields() []*ResultField

GetResultFields implements ResultSetNode interface.

func (*SelectStmt) SetResultFields

func (rs *SelectStmt) SetResultFields(rfs []*ResultField)

SetResultFields implements ResultSetNode interface.

type SelectStmtOpts

type SelectStmtOpts struct {
	Distinct      bool
	SQLCache      bool
	CalcFoundRows bool
	Priority      mysql.PriorityEnum
	TableHints    []*TableOptimizerHint
}

SelectStmtOpts wrap around select hints and switches

type SensitiveStmtNode

type SensitiveStmtNode interface {
	StmtNode
	// SecureText is different from Text that it hide password information.
	SecureText() string
}

SensitiveStmtNode overloads StmtNode and provides a SecureText method.

type SetPwdStmt

type SetPwdStmt struct {
	User     *auth.UserIdentity
	Password string
	// contains filtered or unexported fields
}

SetPwdStmt is a statement to assign a password to user account. See https://dev.mysql.com/doc/refman/5.7/en/set-password.html

func (*SetPwdStmt) Accept

func (n *SetPwdStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*SetPwdStmt) SecureText

func (n *SetPwdStmt) SecureText() string

SecureText implements SensitiveStatement interface.

type SetStmt

type SetStmt struct {

	// Variables is the list of variable assignment.
	Variables []*VariableAssignment
	// contains filtered or unexported fields
}

SetStmt is the statement to set variables.

func (*SetStmt) Accept

func (n *SetStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type ShowStmt

type ShowStmt struct {
	Tp     ShowStmtType // Databases/Tables/Columns/....
	DBName string
	Table  *TableName  // Used for showing columns.
	Column *ColumnName // Used for `desc table column`.
	Flag   int         // Some flag parsed from sql, such as FULL.
	Full   bool
	User   *auth.UserIdentity // Used for show grants.

	// GlobalScope is used by show variables
	GlobalScope bool
	Pattern     *PatternLikeExpr
	Where       ExprNode
	// contains filtered or unexported fields
}

ShowStmt is a statement to provide information about databases, tables, columns and so on. See https://dev.mysql.com/doc/refman/5.7/en/show.html

func (*ShowStmt) Accept

func (n *ShowStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ShowStmt) GetResultFields

func (rs *ShowStmt) GetResultFields() []*ResultField

GetResultFields implements ResultSetNode interface.

func (*ShowStmt) SetResultFields

func (rs *ShowStmt) SetResultFields(rfs []*ResultField)

SetResultFields implements ResultSetNode interface.

type ShowStmtType

type ShowStmtType int

ShowStmtType is the type for SHOW statement.

type Statement

type Statement interface {
	// OriginText gets the origin SQL text.
	OriginText() string

	// Exec executes SQL and gets a Recordset.
	Exec(ctx context.Context) (RecordSet, error)

	// IsPrepared returns whether this statement is prepared statement.
	IsPrepared() bool
}

Statement is an interface for SQL execution. NOTE: all Statement implementations must be safe for concurrent using by multiple goroutines. If the Exec method requires any Execution domain local data, they must be held out of the implementing instance.

type StmtNode

type StmtNode interface {
	Node
	// contains filtered or unexported methods
}

StmtNode represents statement node. Name of implementations should have 'Stmt' suffix.

type SubqueryExec

type SubqueryExec interface {
	// EvalRows executes the subquery and returns the multi rows with rowCount.
	// rowCount < 0 means no limit.
	// If the ColumnCount is 1, we will return a column result like {1, 2, 3},
	// otherwise, we will return a table result like {{1, 1}, {2, 2}}.
	EvalRows(ctx context.Context, rowCount int) ([]types.Datum, error)

	// ColumnCount returns column count for the sub query.
	ColumnCount() (int, error)
}

SubqueryExec represents a subquery executor interface. This interface is implemented in executor and used in plan/evaluator. It will execute the subselect and get the result.

type SubqueryExpr

type SubqueryExpr struct {

	// Query is the query SelectNode.
	Query        ResultSetNode
	SubqueryExec SubqueryExec
	Evaluated    bool
	Correlated   bool
	MultiRows    bool
	Exists       bool
	// contains filtered or unexported fields
}

SubqueryExpr represents a subquery.

func (*SubqueryExpr) Accept

func (n *SubqueryExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*SubqueryExpr) GetDatum

func (en *SubqueryExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*SubqueryExpr) GetFlag

func (en *SubqueryExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*SubqueryExpr) GetResultFields

func (n *SubqueryExpr) GetResultFields() []*ResultField

GetResultFields implements ResultSetNode interface.

func (*SubqueryExpr) GetType

func (en *SubqueryExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*SubqueryExpr) SetDatum

func (en *SubqueryExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*SubqueryExpr) SetFlag

func (en *SubqueryExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*SubqueryExpr) SetResultFields

func (n *SubqueryExpr) SetResultFields(rfs []*ResultField)

SetResultFields implements ResultSetNode interface.

func (*SubqueryExpr) SetType

func (en *SubqueryExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type TableName

type TableName struct {
	Schema model.CIStr
	Name   model.CIStr

	DBInfo    *model.DBInfo
	TableInfo *model.TableInfo

	IndexHints []*IndexHint
	// contains filtered or unexported fields
}

TableName represents a table name.

func (*TableName) Accept

func (n *TableName) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*TableName) GetResultFields

func (rs *TableName) GetResultFields() []*ResultField

GetResultFields implements ResultSetNode interface.

func (*TableName) SetResultFields

func (rs *TableName) SetResultFields(rfs []*ResultField)

SetResultFields implements ResultSetNode interface.

func (*TableName) SetText

func (n *TableName) SetText(text string)

SetText implements Node interface.

func (*TableName) Text

func (n *TableName) Text() string

Text implements Node interface.

type TableOptimizerHint

type TableOptimizerHint struct {

	// HintName is the name or alias of the table(s) which the hint will affect.
	// Table hints has no schema info
	// It allows only table name or alias (if table has an alias)
	HintName model.CIStr
	Tables   []model.CIStr
	// contains filtered or unexported fields
}

TableOptimizerHint is Table level optimizer hint

func (*TableOptimizerHint) Accept

func (n *TableOptimizerHint) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*TableOptimizerHint) SetText

func (n *TableOptimizerHint) SetText(text string)

SetText implements Node interface.

func (*TableOptimizerHint) Text

func (n *TableOptimizerHint) Text() string

Text implements Node interface.

type TableOption

type TableOption struct {
	Tp        TableOptionType
	StrValue  string
	UintValue uint64
}

TableOption is used for parsing table option from SQL.

type TableOptionType

type TableOptionType int

TableOptionType is the type for TableOption

const (
	TableOptionNone TableOptionType = iota
	TableOptionEngine
	TableOptionCharset
	TableOptionCollate
	TableOptionAutoIncrement
	TableOptionComment
	TableOptionAvgRowLength
	TableOptionCheckSum
	TableOptionCompression
	TableOptionConnection
	TableOptionPassword
	TableOptionKeyBlockSize
	TableOptionMaxRows
	TableOptionMinRows
	TableOptionDelayKeyWrite
	TableOptionRowFormat
	TableOptionStatsPersistent
)

TableOption types.

type TableRefsClause

type TableRefsClause struct {
	TableRefs *Join
	// contains filtered or unexported fields
}

TableRefsClause represents table references clause in dml statement.

func (*TableRefsClause) Accept

func (n *TableRefsClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*TableRefsClause) SetText

func (n *TableRefsClause) SetText(text string)

SetText implements Node interface.

func (*TableRefsClause) Text

func (n *TableRefsClause) Text() string

Text implements Node interface.

type TableSource

type TableSource struct {

	// Source is the source of the data, can be a TableName,
	// a SelectStmt, a UnionStmt, or a JoinNode.
	Source ResultSetNode

	// AsName is the alias name of the table source.
	AsName model.CIStr
	// contains filtered or unexported fields
}

TableSource represents table source with a name.

func (*TableSource) Accept

func (n *TableSource) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*TableSource) GetResultFields

func (n *TableSource) GetResultFields() []*ResultField

GetResultFields implements ResultSetNode interface.

func (*TableSource) SetResultFields

func (n *TableSource) SetResultFields(rfs []*ResultField)

SetResultFields implements ResultSetNode interface.

func (*TableSource) SetText

func (n *TableSource) SetText(text string)

SetText implements Node interface.

func (*TableSource) Text

func (n *TableSource) Text() string

Text implements Node interface.

type TableToTable

type TableToTable struct {
	OldTable *TableName
	NewTable *TableName
	// contains filtered or unexported fields
}

TableToTable represents renaming old table to new table used in RenameTableStmt.

func (*TableToTable) Accept

func (n *TableToTable) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*TableToTable) SetText

func (n *TableToTable) SetText(text string)

SetText implements Node interface.

func (*TableToTable) Text

func (n *TableToTable) Text() string

Text implements Node interface.

type TrimDirectionType

type TrimDirectionType int

TrimDirectionType is the type for trim direction.

const (
	// TrimBothDefault trims from both direction by default.
	TrimBothDefault TrimDirectionType = iota
	// TrimBoth trims from both direction with explicit notation.
	TrimBoth
	// TrimLeading trims from left.
	TrimLeading
	// TrimTrailing trims from right.
	TrimTrailing
)

type TruncateTableStmt

type TruncateTableStmt struct {
	Table *TableName
	// contains filtered or unexported fields
}

TruncateTableStmt is a statement to empty a table completely. See https://dev.mysql.com/doc/refman/5.7/en/truncate-table.html

func (*TruncateTableStmt) Accept

func (n *TruncateTableStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type TypeOpt

type TypeOpt struct {
	IsUnsigned bool
	IsZerofill bool
}

TypeOpt is used for parsing data type option from SQL.

type UnaryOperationExpr

type UnaryOperationExpr struct {

	// Op is the operator opcode.
	Op opcode.Op
	// V is the unary expression.
	V ExprNode
	// contains filtered or unexported fields
}

UnaryOperationExpr is the expression for unary operator.

func (*UnaryOperationExpr) Accept

func (n *UnaryOperationExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*UnaryOperationExpr) GetDatum

func (en *UnaryOperationExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*UnaryOperationExpr) GetFlag

func (en *UnaryOperationExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*UnaryOperationExpr) GetType

func (en *UnaryOperationExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*UnaryOperationExpr) SetDatum

func (en *UnaryOperationExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*UnaryOperationExpr) SetFlag

func (en *UnaryOperationExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*UnaryOperationExpr) SetType

func (en *UnaryOperationExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type UnionSelectList

type UnionSelectList struct {
	Selects []*SelectStmt
	// contains filtered or unexported fields
}

UnionSelectList represents the select list in a union statement.

func (*UnionSelectList) Accept

func (n *UnionSelectList) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*UnionSelectList) SetText

func (n *UnionSelectList) SetText(text string)

SetText implements Node interface.

func (*UnionSelectList) Text

func (n *UnionSelectList) Text() string

Text implements Node interface.

type UnionStmt

type UnionStmt struct {
	Distinct   bool
	SelectList *UnionSelectList
	OrderBy    *OrderByClause
	Limit      *Limit
	// contains filtered or unexported fields
}

UnionStmt represents "union statement" See https://dev.mysql.com/doc/refman/5.7/en/union.html

func (*UnionStmt) Accept

func (n *UnionStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*UnionStmt) GetResultFields

func (rs *UnionStmt) GetResultFields() []*ResultField

GetResultFields implements ResultSetNode interface.

func (*UnionStmt) SetResultFields

func (rs *UnionStmt) SetResultFields(rfs []*ResultField)

SetResultFields implements ResultSetNode interface.

type UpdateStmt

type UpdateStmt struct {
	TableRefs     *TableRefsClause
	List          []*Assignment
	Where         ExprNode
	Order         *OrderByClause
	Limit         *Limit
	LowPriority   bool
	IgnoreErr     bool
	MultipleTable bool
	// contains filtered or unexported fields
}

UpdateStmt is a statement to update columns of existing rows in tables with new values. See https://dev.mysql.com/doc/refman/5.7/en/update.html

func (*UpdateStmt) Accept

func (n *UpdateStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type UseStmt

type UseStmt struct {
	DBName string
	// contains filtered or unexported fields
}

UseStmt is a statement to use the DBName database as the current database. See https://dev.mysql.com/doc/refman/5.7/en/use.html

func (*UseStmt) Accept

func (n *UseStmt) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

type UserSpec

type UserSpec struct {
	User    *auth.UserIdentity
	AuthOpt *AuthOption
}

UserSpec is used for parsing create user statement.

func (*UserSpec) SecurityString

func (u *UserSpec) SecurityString() string

SecurityString formats the UserSpec without password information.

type ValueExpr

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

ValueExpr is the simple value expression.

func NewValueExpr

func NewValueExpr(value interface{}) *ValueExpr

NewValueExpr creates a ValueExpr with value, and sets default field type.

func (*ValueExpr) Accept

func (n *ValueExpr) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

func (*ValueExpr) GetDatum

func (en *ValueExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*ValueExpr) GetFlag

func (en *ValueExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*ValueExpr) GetProjectionOffset

func (n *ValueExpr) GetProjectionOffset() int

GetProjectionOffset returns ValueExpr.projectionOffset.

func (*ValueExpr) GetType

func (en *ValueExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*ValueExpr) SetDatum

func (en *ValueExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*ValueExpr) SetFlag

func (en *ValueExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*ValueExpr) SetProjectionOffset

func (n *ValueExpr) SetProjectionOffset(offset int)

SetProjectionOffset sets ValueExpr.projectionOffset for logical plan builder.

func (*ValueExpr) SetType

func (en *ValueExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type ValuesExpr

type ValuesExpr struct {

	// Column is column name.
	Column *ColumnNameExpr
	// contains filtered or unexported fields
}

ValuesExpr is the expression used in INSERT VALUES.

func (*ValuesExpr) Accept

func (n *ValuesExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*ValuesExpr) GetDatum

func (en *ValuesExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*ValuesExpr) GetFlag

func (en *ValuesExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*ValuesExpr) GetType

func (en *ValuesExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*ValuesExpr) SetDatum

func (en *ValuesExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*ValuesExpr) SetFlag

func (en *ValuesExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*ValuesExpr) SetType

func (en *ValuesExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type VariableAssignment

type VariableAssignment struct {
	Name     string
	Value    ExprNode
	IsGlobal bool
	IsSystem bool

	// ExtendValue is a way to store extended info.
	// VariableAssignment should be able to store information for SetCharset/SetPWD Stmt.
	// For SetCharsetStmt, Value is charset, ExtendValue is collation.
	// TODO: Use SetStmt to implement set password statement.
	ExtendValue *ValueExpr
	// contains filtered or unexported fields
}

VariableAssignment is a variable assignment struct.

func (*VariableAssignment) Accept

func (n *VariableAssignment) Accept(v Visitor) (Node, bool)

Accept implements Node interface.

func (*VariableAssignment) SetText

func (n *VariableAssignment) SetText(text string)

SetText implements Node interface.

func (*VariableAssignment) Text

func (n *VariableAssignment) Text() string

Text implements Node interface.

type VariableExpr

type VariableExpr struct {

	// Name is the variable name.
	Name string
	// IsGlobal indicates whether this variable is global.
	IsGlobal bool
	// IsSystem indicates whether this variable is a system variable in current session.
	IsSystem bool
	// Value is the variable value.
	Value ExprNode
	// contains filtered or unexported fields
}

VariableExpr is the expression for variable.

func (*VariableExpr) Accept

func (n *VariableExpr) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*VariableExpr) GetDatum

func (en *VariableExpr) GetDatum() *types.Datum

GetDatum implements ExprNode interface.

func (*VariableExpr) GetFlag

func (en *VariableExpr) GetFlag() uint64

GetFlag implements ExprNode interface.

func (*VariableExpr) GetType

func (en *VariableExpr) GetType() *types.FieldType

GetType implements ExprNode interface.

func (*VariableExpr) SetDatum

func (en *VariableExpr) SetDatum(datum types.Datum)

SetDatum implements ExprNode interface.

func (*VariableExpr) SetFlag

func (en *VariableExpr) SetFlag(flag uint64)

SetFlag implements ExprNode interface.

func (*VariableExpr) SetType

func (en *VariableExpr) SetType(tp *types.FieldType)

SetType implements ExprNode interface.

type Visitor

type Visitor interface {
	// Enter is called before children nodes are visited.
	// The returned node must be the same type as the input node n.
	// skipChildren returns true means children nodes should be skipped,
	// this is useful when work is done in Enter and there is no need to visit children.
	Enter(n Node) (node Node, skipChildren bool)
	// Leave is called after children nodes have been visited.
	// The returned node's type can be different from the input node if it is a ExprNode,
	// Non-expression node must be the same type as the input node n.
	// ok returns false to stop visiting.
	Leave(n Node) (node Node, ok bool)
}

Visitor visits a Node.

type WhenClause

type WhenClause struct {

	// Expr is the condition expression in WhenClause.
	Expr ExprNode
	// Result is the result expression in WhenClause.
	Result ExprNode
	// contains filtered or unexported fields
}

WhenClause is the when clause in Case expression for "when condition then result".

func (*WhenClause) Accept

func (n *WhenClause) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*WhenClause) SetText

func (n *WhenClause) SetText(text string)

SetText implements Node interface.

func (*WhenClause) Text

func (n *WhenClause) Text() string

Text implements Node interface.

type WildCardField

type WildCardField struct {
	Table  model.CIStr
	Schema model.CIStr
	// contains filtered or unexported fields
}

WildCardField is a special type of select field content.

func (*WildCardField) Accept

func (n *WildCardField) Accept(v Visitor) (Node, bool)

Accept implements Node Accept interface.

func (*WildCardField) SetText

func (n *WildCardField) SetText(text string)

SetText implements Node interface.

func (*WildCardField) Text

func (n *WildCardField) Text() string

Text implements Node interface.

Jump to

Keyboard shortcuts

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