expression

package
v0.0.0-...-e065498 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConvertToBinary is a conversion to binary.
	ConvertToBinary = "binary"
	// ConvertToChar is a conversion to char.
	ConvertToChar = "char"
	// ConvertToNChar is a conversion to nchar.
	ConvertToNChar = "nchar"
	// ConvertToDate is a conversion to date.
	ConvertToDate = "date"
	// ConvertToDatetime is a conversion to datetime.
	ConvertToDatetime = "datetime"
	// ConvertToDecimal is a conversion to decimal.
	ConvertToDecimal = "decimal"
	// ConvertToDouble is a conversion to double.
	ConvertToDouble = "double"
	// ConvertToJSON is a conversion to json.
	ConvertToJSON = "json"
	// ConvertToReal is a conversion to double.
	ConvertToReal = "real"
	// ConvertToSigned is a conversion to signed.
	ConvertToSigned = "signed"
	// ConvertToTime is a conversion to time.
	ConvertToTime = "time"
	// ConvertToUnsigned is a conversion to unsigned.
	ConvertToUnsigned = "unsigned"
)
View Source
const ERDivisionByZero = 1365
View Source
const IsFalseStr = "IS FALSE"
View Source
const IsTrueStr = "IS TRUE"

Variables

View Source
var (
	// ErrAutoIncrementUnsupported is returned when table does not support AUTO_INCREMENT.
	ErrAutoIncrementUnsupported = errors.NewKind("table %s does not support AUTO_INCREMENT columns")
	// ErrNoAutoIncrementCols is returned when table has no AUTO_INCREMENT columns.
	ErrNoAutoIncrementCols = errors.NewKind("table %s has no AUTO_INCREMENT columns")
)
View Source
var ErrConvertExpression = errors.NewKind("expression '%v': couldn't convert to %v")

ErrConvertExpression is returned when a conversion is not possible.

View Source
var ErrIndexOutOfBounds = errors.NewKind("unable to find field with index %d in row of %d columns")

ErrIndexOutOfBounds is returned when the field index is out of the bounds.

View Source
var ErrIntDivDataOutOfRange = errors.NewKind("BIGINT value is out of range (%s DIV %s)")
View Source
var ErrInvalidOffset = errors.NewKind("offset must be a non-negative integer; found: %v")
View Source
var ErrInvalidRegexp = errors.NewKind("Invalid regular expression: %s")
View Source
var ErrNilOperand = errors.NewKind("nil operand found in comparison")

ErrNilOperand ir returned if some or both of the comparison's operands is nil.

View Source
var ErrUnresolvedTableFunction = errors.NewKind("unresolved table function")

ErrUnresolvedTableFunction is thrown when a table function cannot be resolved

View Source
var (
	// ErrUnsupportedInOperand is returned when there is an invalid righthand
	// operand in an IN operator.
	ErrUnsupportedInOperand = errors.NewKind("right operand in IN operation must be tuple, but is %T")
)

Functions

func ContainsImpreciseComparison

func ContainsImpreciseComparison(e sql.Expression) bool

ContainsImpreciseComparison searches an expression tree for comparison expressions that require a conversion or type promotion. This utility helps determine if filter predicates can be pushed down.

func Dispose

func Dispose(e sql.Expression)

func ExpressionsResolved

func ExpressionsResolved(exprs ...sql.Expression) bool

ExpressionsResolve returns whether all the expressions in the slice given are resolved

func GetCollationViaCoercion

func GetCollationViaCoercion(expr sql.Expression) (sql.CollationID, int)

GetCollationViaCoercion returns the collation and coercibility value that best represents the expression. This is determined by the rules of coercibility as defined by MySQL (https://dev.mysql.com/doc/refman/8.0/en/charset-collation-coercibility.html). In short, the lower the value of the returned integer, the more explicit the defined collation. A value of 0 indicates that an explicit COLLATE was given. Returns sql.Collation_Unspecified if the expression in invalid in some way.

TODO: This function's implementation is extremely basic, and is sure to return an incorrect result in some cases. A more accurate implementation would have each expression return its own collation and coercion values.

func GetDecimalPrecisionAndScale

func GetDecimalPrecisionAndScale(val string) (uint8, uint8)

GetDecimalPrecisionAndScale returns precision and scale for given string formatted float/double number.

func GetPrecisionAndScale

func GetPrecisionAndScale(val interface{}) (uint8, uint8)

GetPrecisionAndScale converts the value to string format and parses it to get the precision and scale.

func IsBinary

func IsBinary(e sql.Expression) bool

IsBinary returns whether the expression is binary or not.

func IsBindVar

func IsBindVar(e sql.Expression) bool

func IsUnary

func IsUnary(e sql.Expression) bool

IsUnary returns whether the expression is unary or not.

func JoinAnd

func JoinAnd(exprs ...sql.Expression) sql.Expression

JoinAnd joins several expressions with And.

func LiteralToInt

func LiteralToInt(e sql.Expression) (int, error)

LiteralToInt extracts a non-negative integer from an expression.Literal, or errors

func NewAnd

func NewAnd(left, right sql.Expression) sql.Expression

NewAnd creates a new And expression.

func NewBinary

func NewBinary(e sql.Expression) sql.Expression

func NewBindVar

func NewBindVar(name string) sql.Expression

func NewLike

func NewLike(left, right, escape sql.Expression) sql.Expression

NewLike creates a new LIKE expression.

func NewNotInTuple

func NewNotInTuple(left sql.Expression, right sql.Expression) sql.Expression

NewNotInTuple creates a new NotInTuple expression.

func NewOr

func NewOr(left, right sql.Expression) sql.Expression

NewOr creates a new Or expression.

func NewSetField

func NewSetField(left, expr sql.Expression) sql.Expression

NewSetField creates a new SetField expression.

func NewXor

func NewXor(left, right sql.Expression) sql.Expression

NewXor creates a new Xor expression.

func ResolveCoercibility

func ResolveCoercibility(leftCollation sql.CollationID, leftCoercibility int, rightCollation sql.CollationID, rightCoercibility int) (sql.CollationID, error)

ResolveCoercibility returns the collation to use by comparing coercibility, along with giving priority to binary collations. This is an approximation of MySQL's coercibility rules: https://dev.mysql.com/doc/refman/8.0/en/charset-collation-coercibility.html

func SchemaToGetFields

func SchemaToGetFields(s sql.Schema) []sql.Expression

SchemaToGetFields takes a schema and returns an expression array of GetFields.

func WrapExpressions

func WrapExpressions(exprs ...sql.Expression) []sql.Expression

WrapExpressions takes in a number of expressions and wraps each one, returning the resulting slice. Useful for when an expression in a slice may be nil.

Types

type Alias

type Alias struct {
	UnaryExpression
	// contains filtered or unexported fields
}

Alias is a node that gives a name to an expression.

func NewAlias

func NewAlias(name string, expr sql.Expression) *Alias

NewAlias returns a new Alias node.

func (*Alias) DebugString

func (e *Alias) DebugString() string

func (*Alias) Eval

func (e *Alias) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Alias) Name

func (e *Alias) Name() string

Name implements the Nameable interface.

func (*Alias) String

func (e *Alias) String() string

func (*Alias) Type

func (e *Alias) Type() sql.Type

Type returns the type of the expression.

func (*Alias) WithChildren

func (e *Alias) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type AliasReference

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

AliasReference is a named reference to an aliased expression.

func NewAliasReference

func NewAliasReference(name string) *AliasReference

NewAliasReference creates a new AliasReference from the specified alias name.

func (AliasReference) Children

func (a AliasReference) Children() []sql.Expression

func (AliasReference) Eval

func (a AliasReference) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (AliasReference) IsNullable

func (a AliasReference) IsNullable() bool

func (AliasReference) Name

func (a AliasReference) Name() string

func (AliasReference) Resolved

func (a AliasReference) Resolved() bool

func (AliasReference) String

func (a AliasReference) String() string

func (AliasReference) Table

func (a AliasReference) Table() string

func (AliasReference) Type

func (a AliasReference) Type() sql.Type

func (AliasReference) WithChildren

func (a AliasReference) WithChildren(children ...sql.Expression) (sql.Expression, error)

type And

type And struct {
	BinaryExpression
}

And checks whether two expressions are true.

func (*And) DebugString

func (a *And) DebugString() string

func (*And) Eval

func (a *And) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*And) String

func (a *And) String() string

func (*And) Type

func (*And) Type() sql.Type

Type implements the Expression interface.

func (*And) WithChildren

func (a *And) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Arithmetic

type Arithmetic struct {
	BinaryExpression
	Op string
	// contains filtered or unexported fields
}

Arithmetic expressions include plus, minus and multiplication (+, -, *) operations.

func NewArithmetic

func NewArithmetic(left, right sql.Expression, op string) *Arithmetic

NewArithmetic creates a new Arithmetic sql.Expression.

func NewMinus

func NewMinus(left, right sql.Expression) *Arithmetic

NewMinus creates a new Arithmetic - sql.Expression.

func NewMult

func NewMult(left, right sql.Expression) *Arithmetic

NewMult creates a new Arithmetic * sql.Expression.

func NewPlus

func NewPlus(left, right sql.Expression) *Arithmetic

NewPlus creates a new Arithmetic + sql.Expression.

func (*Arithmetic) DebugString

func (a *Arithmetic) DebugString() string

func (*Arithmetic) Eval

func (a *Arithmetic) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Arithmetic) IsNullable

func (a *Arithmetic) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*Arithmetic) LeftChild

func (a *Arithmetic) LeftChild() sql.Expression

func (*Arithmetic) Operator

func (a *Arithmetic) Operator() string

func (*Arithmetic) RightChild

func (a *Arithmetic) RightChild() sql.Expression

func (*Arithmetic) SetOpCount

func (a *Arithmetic) SetOpCount(i int32)

func (*Arithmetic) String

func (a *Arithmetic) String() string

func (*Arithmetic) Type

func (a *Arithmetic) Type() sql.Type

Type returns the greatest type for given operation.

func (*Arithmetic) WithChildren

func (a *Arithmetic) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type ArithmeticOp

type ArithmeticOp interface {
	sql.Expression
	LeftChild() sql.Expression
	RightChild() sql.Expression
	SetOpCount(int32)
	Operator() string
}

ArithmeticOp implements an arithmetic expression. Since we had separate expressions for division and mod operation, we need to group all arithmetic together. Use this expression to define any arithmetic operation that is separately implemented from Arithmetic expression in the future.

type AutoIncrement

type AutoIncrement struct {
	UnaryExpression
	// contains filtered or unexported fields
}

AutoIncrement implements AUTO_INCREMENT

func NewAutoIncrement

func NewAutoIncrement(ctx *sql.Context, table sql.Table, given sql.Expression) (*AutoIncrement, error)

NewAutoIncrement creates a new AutoIncrement expression.

func NewAutoIncrementForColumn

func NewAutoIncrementForColumn(ctx *sql.Context, table sql.Table, autoCol *sql.Column, given sql.Expression) (*AutoIncrement, error)

NewAutoIncrementForColumn creates a new AutoIncrement expression for the column given.

func (*AutoIncrement) Children

func (i *AutoIncrement) Children() []sql.Expression

Children implements the Expression interface.

func (*AutoIncrement) Eval

func (i *AutoIncrement) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*AutoIncrement) IsNullable

func (i *AutoIncrement) IsNullable() bool

IsNullable implements the Expression interface.

func (*AutoIncrement) String

func (i *AutoIncrement) String() string

func (*AutoIncrement) Type

func (i *AutoIncrement) Type() sql.Type

Type implements the Expression interface.

func (*AutoIncrement) WithChildren

func (i *AutoIncrement) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Between

type Between struct {
	Val   sql.Expression
	Lower sql.Expression
	Upper sql.Expression
}

Between checks a value is between two given values.

func NewBetween

func NewBetween(val, lower, upper sql.Expression) *Between

NewBetween creates a new Between expression.

func (*Between) Children

func (b *Between) Children() []sql.Expression

Children implements the Expression interface.

func (*Between) DebugString

func (b *Between) DebugString() string

func (*Between) Eval

func (b *Between) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Between) IsNullable

func (b *Between) IsNullable() bool

IsNullable implements the Expression interface.

func (*Between) Resolved

func (b *Between) Resolved() bool

Resolved implements the Expression interface.

func (*Between) String

func (b *Between) String() string

func (*Between) Type

func (*Between) Type() sql.Type

Type implements the Expression interface.

func (*Between) WithChildren

func (b *Between) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Binary

type Binary struct {
	UnaryExpression
}

The BINARY operator converts the expression to a binary string (a string that has the binary character set and binary collation). A common use for BINARY is to force a character string comparison to be done byte by byte using numeric byte values rather than character by character. The BINARY operator also causes trailing spaces in comparisons to be significant.

cc: https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#operator_binary

func (*Binary) Eval

func (b *Binary) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

func (*Binary) String

func (b *Binary) String() string

func (*Binary) Type

func (b *Binary) Type() sql.Type

func (*Binary) WithChildren

func (b *Binary) WithChildren(children ...sql.Expression) (sql.Expression, error)

type BinaryExpression

type BinaryExpression struct {
	Left  sql.Expression
	Right sql.Expression
}

BinaryExpression is an expression that has two children.

func (*BinaryExpression) Children

func (p *BinaryExpression) Children() []sql.Expression

Children implements the Expression interface.

func (*BinaryExpression) IsNullable

func (p *BinaryExpression) IsNullable() bool

IsNullable returns whether the expression can be null.

func (*BinaryExpression) Resolved

func (p *BinaryExpression) Resolved() bool

Resolved implements the Expression interface.

type BindVar

type BindVar struct {
	Name string
	Typ  sql.Type
}

func (*BindVar) Children

func (bv *BindVar) Children() []sql.Expression

func (*BindVar) Eval

func (bv *BindVar) Eval(*sql.Context, sql.Row) (interface{}, error)

func (*BindVar) IsNullable

func (bv *BindVar) IsNullable() bool

func (*BindVar) Resolved

func (bv *BindVar) Resolved() bool

func (*BindVar) String

func (bv *BindVar) String() string

func (*BindVar) Type

func (bv *BindVar) Type() sql.Type

func (*BindVar) WithChildren

func (bv *BindVar) WithChildren(children ...sql.Expression) (sql.Expression, error)

type BitOp

type BitOp struct {
	BinaryExpression
	Op string
}

BitOp expressions include BIT -AND, -OR and -XOR (&, | and ^) operations https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html

func NewBitAnd

func NewBitAnd(left, right sql.Expression) *BitOp

NewBitAnd creates a new BitOp & sql.Expression.

func NewBitOp

func NewBitOp(left, right sql.Expression, op string) *BitOp

NewBitOp creates a new BitOp sql.Expression.

func NewBitOr

func NewBitOr(left, right sql.Expression) *BitOp

NewBitOr creates a new BitOp | sql.Expression.

func NewBitXor

func NewBitXor(left, right sql.Expression) *BitOp

NewBitXor creates a new BitOp ^ sql.Expression.

func NewShiftLeft

func NewShiftLeft(left, right sql.Expression) *BitOp

NewShiftLeft creates a new BitOp << sql.Expression.

func NewShiftRight

func NewShiftRight(left, right sql.Expression) *BitOp

NewShiftRight creates a new BitOp >> sql.Expression.

func (*BitOp) DebugString

func (b *BitOp) DebugString() string

func (*BitOp) Eval

func (b *BitOp) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*BitOp) IsNullable

func (b *BitOp) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*BitOp) String

func (b *BitOp) String() string

func (*BitOp) Type

func (b *BitOp) Type() sql.Type

Type returns the greatest type for given operation.

func (*BitOp) WithChildren

func (b *BitOp) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Case

type Case struct {
	Expr     sql.Expression
	Branches []CaseBranch
	Else     sql.Expression
}

Case is an expression that returns the value of one of its branches when a condition is met.

func NewCase

func NewCase(expr sql.Expression, branches []CaseBranch, elseExpr sql.Expression) *Case

NewCase returns an new Case expression.

func (*Case) Children

func (c *Case) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*Case) DebugString

func (c *Case) DebugString() string

func (*Case) Eval

func (c *Case) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*Case) IsNullable

func (c *Case) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*Case) Resolved

func (c *Case) Resolved() bool

Resolved implements the sql.Expression interface.

func (*Case) String

func (c *Case) String() string

func (*Case) Type

func (c *Case) Type() sql.Type

Type implements the sql.Expression interface.

func (*Case) WithChildren

func (c *Case) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type CaseBranch

type CaseBranch struct {
	Cond  sql.Expression
	Value sql.Expression
}

CaseBranch is a single branch of a case expression.

type CollatedExpression

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

CollatedExpression represents an expression (returning a string or byte slice) that carries a collation (which implicitly also carries a character set). This does not handle any encoding or decoding of the character set, as this is strictly for collations.

func NewCollatedExpression

func NewCollatedExpression(expr sql.Expression, collation sql.CollationID) *CollatedExpression

NewCollatedExpression creates a new CollatedExpression expression. If the given expression is already a CollatedExpression, then the previous collation is overriden with the given one.

func (*CollatedExpression) Child

func (ce *CollatedExpression) Child() sql.Expression

Child returns the inner expression.

func (*CollatedExpression) Children

func (ce *CollatedExpression) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*CollatedExpression) DebugString

func (ce *CollatedExpression) DebugString() string

DebugString implements the sql.DebugStringer interface.

func (*CollatedExpression) Eval

func (ce *CollatedExpression) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*CollatedExpression) IsNullable

func (ce *CollatedExpression) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*CollatedExpression) Resolved

func (ce *CollatedExpression) Resolved() bool

Resolved implements the sql.Expression interface.

func (*CollatedExpression) String

func (ce *CollatedExpression) String() string

func (*CollatedExpression) Type

func (ce *CollatedExpression) Type() sql.Type

Type implements the sql.Expression interface.

func (*CollatedExpression) WithChildren

func (ce *CollatedExpression) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the sql.Expression interface.

type Comparer

type Comparer interface {
	sql.Expression
	Compare(ctx *sql.Context, row sql.Row) (int, error)
	Left() sql.Expression
	Right() sql.Expression
}

Comparer implements a comparison expression.

type Convert

type Convert struct {
	UnaryExpression
	// contains filtered or unexported fields
}

Convert represent a CAST(x AS T) or CONVERT(x, T) operation that casts x expression to type T.

func NewConvert

func NewConvert(expr sql.Expression, castToType string) *Convert

NewConvert creates a new Convert expression.

func (*Convert) Eval

func (c *Convert) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Convert) IsNullable

func (c *Convert) IsNullable() bool

IsNullable implements the Expression interface.

func (*Convert) String

func (c *Convert) String() string

Name implements the Expression interface.

func (*Convert) Type

func (c *Convert) Type() sql.Type

Type implements the Expression interface.

func (*Convert) WithChildren

func (c *Convert) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type DefaultColumn

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

DefaultColumn is a default expression of a column that is not yet resolved.

func NewDefaultColumn

func NewDefaultColumn(name string) *DefaultColumn

NewDefaultColumn creates a new NewDefaultColumn expression.

func (*DefaultColumn) Children

func (*DefaultColumn) Children() []sql.Expression

Children implements the sql.Expression interface. The function returns always nil

func (*DefaultColumn) Eval

func (*DefaultColumn) Eval(ctx *sql.Context, r sql.Row) (interface{}, error)

Eval implements the sql.Expression interface. The function always panics!

func (*DefaultColumn) IsNullable

func (*DefaultColumn) IsNullable() bool

IsNullable implements the sql.Expression interface. The function always panics!

func (*DefaultColumn) Name

func (c *DefaultColumn) Name() string

Name implements the sql.Nameable interface.

func (*DefaultColumn) Resolved

func (*DefaultColumn) Resolved() bool

Resolved implements the sql.Expression interface. The function returns always false

func (*DefaultColumn) String

func (c *DefaultColumn) String() string

String implements the Stringer The function returns column's name (can be an empty string)

func (*DefaultColumn) Type

func (*DefaultColumn) Type() sql.Type

Type implements the sql.Expression interface. The function always panics!

func (*DefaultColumn) WithChildren

func (c *DefaultColumn) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type DistinctExpression

type DistinctExpression struct {
	Child sql.Expression
	// contains filtered or unexported fields
}

func NewDistinctExpression

func NewDistinctExpression(e sql.Expression) *DistinctExpression

func (*DistinctExpression) Children

func (de *DistinctExpression) Children() []sql.Expression

func (*DistinctExpression) Dispose

func (de *DistinctExpression) Dispose()

func (*DistinctExpression) Eval

func (de *DistinctExpression) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Returns the child value if the cache hasn't seen the value before otherwise returns nil. Since NULLs are ignored in aggregate expressions that use DISTINCT this is a valid return scheme.

func (*DistinctExpression) IsNullable

func (de *DistinctExpression) IsNullable() bool

func (*DistinctExpression) Resolved

func (de *DistinctExpression) Resolved() bool

func (*DistinctExpression) String

func (de *DistinctExpression) String() string

func (*DistinctExpression) Type

func (de *DistinctExpression) Type() sql.Type

func (*DistinctExpression) WithChildren

func (de *DistinctExpression) WithChildren(children ...sql.Expression) (sql.Expression, error)

type Div

type Div struct {
	BinaryExpression
	// contains filtered or unexported fields
}

Div expression represents "/" arithmetic operation

func NewDiv

func NewDiv(left, right sql.Expression) *Div

NewDiv creates a new Div / sql.Expression.

func (*Div) DebugString

func (d *Div) DebugString() string

func (*Div) Eval

func (d *Div) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Div) IsNullable

func (d *Div) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*Div) LeftChild

func (d *Div) LeftChild() sql.Expression

func (*Div) Operator

func (d *Div) Operator() string

func (*Div) RightChild

func (d *Div) RightChild() sql.Expression

func (*Div) SetOpCount

func (d *Div) SetOpCount(i int32)

func (*Div) String

func (d *Div) String() string

func (*Div) Type

func (d *Div) Type() sql.Type

Type returns the greatest type for given operation.

func (*Div) WithChildren

func (d *Div) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Equals

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

Equals is a comparison that checks an expression is equal to another.

func NewEquals

func NewEquals(left sql.Expression, right sql.Expression) *Equals

NewEquals returns a new Equals expression.

func (*Equals) Compare

func (c *Equals) Compare(ctx *sql.Context, row sql.Row) (int, error)

Compare the two given values using the types of the expressions in the comparison. Since both types should be equal, it does not matter which type is used, but for reference, the left type is always used.

func (*Equals) DebugString

func (e *Equals) DebugString() string

func (*Equals) Eval

func (e *Equals) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Equals) Left

func (c *Equals) Left() sql.Expression

Left implements Comparer interface

func (*Equals) Right

func (c *Equals) Right() sql.Expression

Right implements Comparer interface

func (*Equals) String

func (e *Equals) String() string

func (*Equals) Type

func (*Equals) Type() sql.Type

Type implements the Expression interface.

func (*Equals) WithChildren

func (e *Equals) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type GetField

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

GetField is an expression to get the field of a table.

func ExtractGetField

func ExtractGetField(e sql.Expression) *GetField

ExtractGetField returns the inner GetField expression from another expression. If there are multiple GetField expressions that are not the same, then none of the GetField expressions are returned.

func NewGetField

func NewGetField(index int, fieldType sql.Type, fieldName string, nullable bool) *GetField

NewGetField creates a GetField expression.

func NewGetFieldWithTable

func NewGetFieldWithTable(index int, fieldType sql.Type, table, fieldName string, nullable bool) *GetField

NewGetFieldWithTable creates a GetField expression with table name. The table name may be an alias.

func (*GetField) Children

func (*GetField) Children() []sql.Expression

Children implements the Expression interface.

func (*GetField) DebugString

func (p *GetField) DebugString() string

func (*GetField) Eval

func (p *GetField) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*GetField) Eval2

func (p *GetField) Eval2(ctx *sql.Context, row sql.Row2) (sql.Value, error)

func (*GetField) Index

func (p *GetField) Index() int

Index returns the index where the GetField will look for the value from a sql.Row.

func (*GetField) IsNullable

func (p *GetField) IsNullable() bool

IsNullable returns whether the field is nullable or not.

func (*GetField) Name

func (p *GetField) Name() string

Name implements the Nameable interface.

func (*GetField) Resolved

func (p *GetField) Resolved() bool

Resolved implements the Expression interface.

func (*GetField) String

func (p *GetField) String() string

func (*GetField) Table

func (p *GetField) Table() string

Table returns the name of the field table.

func (*GetField) Type

func (p *GetField) Type() sql.Type

Type returns the type of the field.

func (*GetField) Type2

func (p *GetField) Type2() sql.Type2

Type2 returns the type of the field, if this field has a sql.Type2.

func (*GetField) WithChildren

func (p *GetField) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

func (*GetField) WithIndex

func (p *GetField) WithIndex(n int) sql.Expression

WithIndex returns this same GetField with a new index.

func (*GetField) WithName

func (p *GetField) WithName(name string) *GetField

WithName returns a copy of this expression with the field name given.

func (*GetField) WithTable

func (p *GetField) WithTable(table string) *GetField

WithTable returns a copy of this expression with the table given

type GreaterThan

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

GreaterThan is a comparison that checks an expression is greater than another.

func NewGreaterThan

func NewGreaterThan(left sql.Expression, right sql.Expression) *GreaterThan

NewGreaterThan creates a new GreaterThan expression.

func (*GreaterThan) Compare

func (c *GreaterThan) Compare(ctx *sql.Context, row sql.Row) (int, error)

Compare the two given values using the types of the expressions in the comparison. Since both types should be equal, it does not matter which type is used, but for reference, the left type is always used.

func (*GreaterThan) DebugString

func (gt *GreaterThan) DebugString() string

func (*GreaterThan) Eval

func (gt *GreaterThan) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*GreaterThan) Left

func (c *GreaterThan) Left() sql.Expression

Left implements Comparer interface

func (*GreaterThan) Right

func (c *GreaterThan) Right() sql.Expression

Right implements Comparer interface

func (*GreaterThan) String

func (gt *GreaterThan) String() string

func (*GreaterThan) Type

func (*GreaterThan) Type() sql.Type

Type implements the Expression interface.

func (*GreaterThan) WithChildren

func (gt *GreaterThan) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type GreaterThanOrEqual

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

GreaterThanOrEqual is a comparison that checks an expression is greater or equal to another.

func NewGreaterThanOrEqual

func NewGreaterThanOrEqual(left sql.Expression, right sql.Expression) *GreaterThanOrEqual

NewGreaterThanOrEqual creates a new GreaterThanOrEqual

func (*GreaterThanOrEqual) Compare

func (c *GreaterThanOrEqual) Compare(ctx *sql.Context, row sql.Row) (int, error)

Compare the two given values using the types of the expressions in the comparison. Since both types should be equal, it does not matter which type is used, but for reference, the left type is always used.

func (*GreaterThanOrEqual) DebugString

func (gte *GreaterThanOrEqual) DebugString() string

func (*GreaterThanOrEqual) Eval

func (gte *GreaterThanOrEqual) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*GreaterThanOrEqual) Left

func (c *GreaterThanOrEqual) Left() sql.Expression

Left implements Comparer interface

func (*GreaterThanOrEqual) Right

func (c *GreaterThanOrEqual) Right() sql.Expression

Right implements Comparer interface

func (*GreaterThanOrEqual) String

func (gte *GreaterThanOrEqual) String() string

func (*GreaterThanOrEqual) Type

func (*GreaterThanOrEqual) Type() sql.Type

Type implements the Expression interface.

func (*GreaterThanOrEqual) WithChildren

func (gte *GreaterThanOrEqual) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type HashInTuple

type HashInTuple struct {
	InTuple
	// contains filtered or unexported fields
}

HashInTuple is an expression that checks an expression is inside a list of expressions using a hashmap.

func NewHashInTuple

func NewHashInTuple(ctx *sql.Context, left, right sql.Expression) (*HashInTuple, error)

NewHashInTuple creates an InTuple expression.

func (*HashInTuple) DebugString

func (hit *HashInTuple) DebugString() string

func (*HashInTuple) Eval

func (hit *HashInTuple) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*HashInTuple) String

func (hit *HashInTuple) String() string

type InTuple

type InTuple struct {
	BinaryExpression
}

InTuple is an expression that checks an expression is inside a list of expressions.

func NewInTuple

func NewInTuple(left sql.Expression, right sql.Expression) *InTuple

NewInTuple creates an InTuple expression.

func (*InTuple) Children

func (in *InTuple) Children() []sql.Expression

Children implements the Expression interface.

func (*InTuple) Compare

func (in *InTuple) Compare(ctx *sql.Context, row sql.Row) (int, error)

func (*InTuple) DebugString

func (in *InTuple) DebugString() string

func (*InTuple) Eval

func (in *InTuple) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*InTuple) Left

func (in *InTuple) Left() sql.Expression

func (*InTuple) Right

func (in *InTuple) Right() sql.Expression

func (*InTuple) String

func (in *InTuple) String() string

func (*InTuple) Type

func (in *InTuple) Type() sql.Type

func (*InTuple) WithChildren

func (in *InTuple) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type IntDiv

type IntDiv struct {
	BinaryExpression
	// contains filtered or unexported fields
}

IntDiv expression represents integer "div" arithmetic operation

func NewIntDiv

func NewIntDiv(left, right sql.Expression) *IntDiv

NewIntDiv creates a new IntDiv 'div' sql.Expression.

func (*IntDiv) DebugString

func (i *IntDiv) DebugString() string

func (*IntDiv) Eval

func (i *IntDiv) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*IntDiv) IsNullable

func (i *IntDiv) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*IntDiv) LeftChild

func (i *IntDiv) LeftChild() sql.Expression

func (*IntDiv) Operator

func (i *IntDiv) Operator() string

func (*IntDiv) RightChild

func (i *IntDiv) RightChild() sql.Expression

func (*IntDiv) SetOpCount

func (i *IntDiv) SetOpCount(i2 int32)

func (*IntDiv) String

func (i *IntDiv) String() string

func (*IntDiv) Type

func (i *IntDiv) Type() sql.Type

Type returns the greatest type for given operation.

func (*IntDiv) WithChildren

func (i *IntDiv) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Interval

type Interval struct {
	UnaryExpression
	Unit string
}

Interval defines a time duration.

func NewInterval

func NewInterval(child sql.Expression, unit string) *Interval

NewInterval creates a new interval expression.

func (*Interval) Eval

func (i *Interval) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*Interval) EvalDelta

func (i *Interval) EvalDelta(ctx *sql.Context, row sql.Row) (*TimeDelta, error)

EvalDelta evaluates the expression returning a TimeDelta. This method should be used instead of Eval, as this expression returns a TimeDelta, which is not a valid value that can be returned in Eval.

func (*Interval) IsNullable

func (i *Interval) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*Interval) String

func (i *Interval) String() string

func (*Interval) Type

func (i *Interval) Type() sql.Type

Type implements the sql.Expression interface.

func (*Interval) WithChildren

func (i *Interval) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type IsNull

type IsNull struct {
	UnaryExpression
}

IsNull is an expression that checks if an expression is null.

func NewIsNull

func NewIsNull(child sql.Expression) *IsNull

NewIsNull creates a new IsNull expression.

func (IsNull) DebugString

func (e IsNull) DebugString() string

func (*IsNull) Eval

func (e *IsNull) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*IsNull) IsNullable

func (e *IsNull) IsNullable() bool

IsNullable implements the Expression interface.

func (IsNull) String

func (e IsNull) String() string

func (*IsNull) Type

func (e *IsNull) Type() sql.Type

Type implements the Expression interface.

func (*IsNull) WithChildren

func (e *IsNull) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type IsTrue

type IsTrue struct {
	UnaryExpression
	// contains filtered or unexported fields
}

IsTrue is an expression that checks if an expression is true.

func NewIsFalse

func NewIsFalse(child sql.Expression) *IsTrue

NewIsFalse creates a new IsTrue expression with its boolean sense inverted (IsFalse, effectively).

func NewIsTrue

func NewIsTrue(child sql.Expression) *IsTrue

NewIsTrue creates a new IsTrue expression.

func (*IsTrue) Eval

func (e *IsTrue) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*IsTrue) IsNullable

func (*IsTrue) IsNullable() bool

IsNullable implements the Expression interface.

func (*IsTrue) String

func (e *IsTrue) String() string

func (*IsTrue) Type

func (*IsTrue) Type() sql.Type

Type implements the Expression interface.

func (*IsTrue) WithChildren

func (e *IsTrue) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type LessThan

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

LessThan is a comparison that checks an expression is less than another.

func NewLessThan

func NewLessThan(left sql.Expression, right sql.Expression) *LessThan

NewLessThan creates a new LessThan expression.

func (*LessThan) Compare

func (c *LessThan) Compare(ctx *sql.Context, row sql.Row) (int, error)

Compare the two given values using the types of the expressions in the comparison. Since both types should be equal, it does not matter which type is used, but for reference, the left type is always used.

func (*LessThan) DebugString

func (lt *LessThan) DebugString() string

func (*LessThan) Eval

func (lt *LessThan) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the expression interface.

func (*LessThan) Left

func (c *LessThan) Left() sql.Expression

Left implements Comparer interface

func (*LessThan) Right

func (c *LessThan) Right() sql.Expression

Right implements Comparer interface

func (*LessThan) String

func (lt *LessThan) String() string

func (*LessThan) Type

func (*LessThan) Type() sql.Type

Type implements the Expression interface.

func (*LessThan) WithChildren

func (lt *LessThan) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type LessThanOrEqual

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

LessThanOrEqual is a comparison that checks an expression is equal or lower than another.

func NewLessThanOrEqual

func NewLessThanOrEqual(left sql.Expression, right sql.Expression) *LessThanOrEqual

NewLessThanOrEqual creates a LessThanOrEqual expression.

func (*LessThanOrEqual) Compare

func (c *LessThanOrEqual) Compare(ctx *sql.Context, row sql.Row) (int, error)

Compare the two given values using the types of the expressions in the comparison. Since both types should be equal, it does not matter which type is used, but for reference, the left type is always used.

func (*LessThanOrEqual) DebugString

func (lte *LessThanOrEqual) DebugString() string

func (*LessThanOrEqual) Eval

func (lte *LessThanOrEqual) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*LessThanOrEqual) Left

func (c *LessThanOrEqual) Left() sql.Expression

Left implements Comparer interface

func (*LessThanOrEqual) Right

func (c *LessThanOrEqual) Right() sql.Expression

Right implements Comparer interface

func (*LessThanOrEqual) String

func (lte *LessThanOrEqual) String() string

func (*LessThanOrEqual) Type

func (*LessThanOrEqual) Type() sql.Type

Type implements the Expression interface.

func (*LessThanOrEqual) WithChildren

func (lte *LessThanOrEqual) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Like

type Like struct {
	BinaryExpression
	Escape sql.Expression
	// contains filtered or unexported fields
}

Like performs pattern matching against two strings.

func (*Like) Eval

func (l *Like) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*Like) String

func (l *Like) String() string

func (*Like) Type

func (l *Like) Type() sql.Type

Type implements the sql.Expression interface.

func (*Like) WithChildren

func (l *Like) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type LikeMatcher

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

LikeMatcher is a collation-supported matcher for LIKE expressions.

func ConstructLikeMatcher

func ConstructLikeMatcher(collation sql.CollationID, pattern string, escape rune) (LikeMatcher, error)

ConstructLikeMatcher returns a new LikeMatcher.

func (LikeMatcher) Match

func (l LikeMatcher) Match(s string) bool

Match returns whether the given string conforms to the nodes contained in this matcher.

func (LikeMatcher) String

func (l LikeMatcher) String() string

String returns the string form of this LIKE expression. If an Escape character was provided, it is used instead of the default.

type Literal

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

Literal represents a literal expression (string, number, bool, ...).

func NewLiteral

func NewLiteral(value interface{}, fieldType sql.Type) *Literal

NewLiteral creates a new Literal expression.

func (*Literal) Children

func (*Literal) Children() []sql.Expression

Children implements the Expression interface.

func (*Literal) DebugString

func (lit *Literal) DebugString() string

func (*Literal) Eval

func (lit *Literal) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Literal) Eval2

func (lit *Literal) Eval2(ctx *sql.Context, row sql.Row2) (sql.Value, error)

func (*Literal) IsNullable

func (lit *Literal) IsNullable() bool

IsNullable implements the Expression interface.

func (*Literal) Resolved

func (lit *Literal) Resolved() bool

Resolved implements the Expression interface.

func (*Literal) String

func (lit *Literal) String() string

func (*Literal) Type

func (lit *Literal) Type() sql.Type

Type implements the Expression interface.

func (*Literal) Type2

func (lit *Literal) Type2() sql.Type2

func (*Literal) Value

func (p *Literal) Value() interface{}

Value returns the literal value.

func (*Literal) WithChildren

func (lit *Literal) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Mod

type Mod struct {
	BinaryExpression
	// contains filtered or unexported fields
}

Mod expression represents "%" arithmetic operation

func NewMod

func NewMod(left, right sql.Expression) *Mod

NewMod creates a new Mod sql.Expression.

func (*Mod) DebugString

func (m *Mod) DebugString() string

func (*Mod) Eval

func (m *Mod) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Mod) IsNullable

func (m *Mod) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*Mod) LeftChild

func (m *Mod) LeftChild() sql.Expression

func (*Mod) Operator

func (m *Mod) Operator() string

func (*Mod) RightChild

func (m *Mod) RightChild() sql.Expression

func (*Mod) SetOpCount

func (m *Mod) SetOpCount(i int32)

func (*Mod) String

func (m *Mod) String() string

func (*Mod) Type

func (m *Mod) Type() sql.Type

Type returns the greatest type for given operation.

func (*Mod) WithChildren

func (m *Mod) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type NamedLiteral

type NamedLiteral struct {
	*Literal
	Name string
}

NamedLiteral represents a literal value, but returns the name field rather than the value for String.

func NewNamedLiteral

func NewNamedLiteral(name string, value interface{}, fieldType sql.Type) NamedLiteral

NewNamedLiteral returns a new NamedLiteral.

func (NamedLiteral) String

func (lit NamedLiteral) String() string

String implements the interface sql.Expression.

type NaryExpression

type NaryExpression struct {
	ChildExpressions []sql.Expression
}

func (*NaryExpression) Children

func (n *NaryExpression) Children() []sql.Expression

Children implements the Expression interface.

func (*NaryExpression) IsNullable

func (n *NaryExpression) IsNullable() bool

IsNullable returns whether the expression can be null.

func (*NaryExpression) Resolved

func (n *NaryExpression) Resolved() bool

Resolved implements the Expression interface.

type Not

type Not struct {
	UnaryExpression
}

Not is a node that negates an expression.

func NewNot

func NewNot(child sql.Expression) *Not

NewNot returns a new Not node.

func (*Not) DebugString

func (e *Not) DebugString() string

func (*Not) Eval

func (e *Not) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Not) String

func (e *Not) String() string

func (*Not) Type

func (e *Not) Type() sql.Type

Type implements the Expression interface.

func (*Not) WithChildren

func (e *Not) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type NullSafeEquals

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

NullSafeEquals is a comparison that checks an expression is equal to another, where NULLs do not coalesce to NULL and two NULLs compare equal to each other.

func NewNullSafeEquals

func NewNullSafeEquals(left sql.Expression, right sql.Expression) *NullSafeEquals

NewNullSafeEquals returns a new NullSafeEquals expression.

func (*NullSafeEquals) Compare

func (e *NullSafeEquals) Compare(ctx *sql.Context, row sql.Row) (int, error)

func (*NullSafeEquals) DebugString

func (e *NullSafeEquals) DebugString() string

func (*NullSafeEquals) Eval

func (e *NullSafeEquals) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*NullSafeEquals) Left

func (c *NullSafeEquals) Left() sql.Expression

Left implements Comparer interface

func (*NullSafeEquals) Right

func (c *NullSafeEquals) Right() sql.Expression

Right implements Comparer interface

func (*NullSafeEquals) String

func (e *NullSafeEquals) String() string

func (*NullSafeEquals) Type

func (e *NullSafeEquals) Type() sql.Type

Type implements the Expression interface.

func (*NullSafeEquals) WithChildren

func (e *NullSafeEquals) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Or

type Or struct {
	BinaryExpression
}

Or checks whether one of the two given expressions is true.

func (*Or) DebugString

func (o *Or) DebugString() string

func (*Or) Eval

func (o *Or) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Or) String

func (o *Or) String() string

func (*Or) Type

func (*Or) Type() sql.Type

Type implements the Expression interface.

func (*Or) WithChildren

func (o *Or) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type ProcedureParam

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

ProcedureParam represents the parameter of a stored procedure or stored function.

func NewProcedureParam

func NewProcedureParam(id int, name string) *ProcedureParam

NewProcedureParam creates a new ProcedureParam expression.

func (*ProcedureParam) Children

func (*ProcedureParam) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*ProcedureParam) Eval

func (pp *ProcedureParam) Eval(ctx *sql.Context, r sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*ProcedureParam) IsNullable

func (*ProcedureParam) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*ProcedureParam) Name

func (pp *ProcedureParam) Name() string

Name implements the Nameable interface.

func (*ProcedureParam) Resolved

func (*ProcedureParam) Resolved() bool

Resolved implements the sql.Expression interface.

func (*ProcedureParam) Set

func (pp *ProcedureParam) Set(val interface{}, valType sql.Type) error

Set sets the value of this procedure parameter to the given value.

func (*ProcedureParam) String

func (pp *ProcedureParam) String() string

String implements the sql.Expression interface.

func (*ProcedureParam) Type

func (pp *ProcedureParam) Type() sql.Type

Type implements the sql.Expression interface.

func (*ProcedureParam) WithChildren

func (pp *ProcedureParam) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the sql.Expression interface.

func (*ProcedureParam) WithParamReference

func (pp *ProcedureParam) WithParamReference(pRef *ProcedureReference) *ProcedureParam

WithParamReference returns a new *ProcedureParam containing the given *ProcedureReference.

type ProcedureReferencable

type ProcedureReferencable interface {
	WithParamReference(pRef *ProcedureReference) sql.Node
}

ProcedureReferencable indicates that a sql.Node takes a *ProcedureReference returns a new copy with the reference set.

type ProcedureReference

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

ProcedureReference contains the state for a single CALL statement of a stored procedure.

func NewProcedureReference

func NewProcedureReference(variableCount int, cursorCount int, handlerCount int) *ProcedureReference

func (*ProcedureReference) CloseAllCursors

func (ppr *ProcedureReference) CloseAllCursors(ctx *sql.Context) error

CloseAllCursors closes all cursors that are still open.

func (*ProcedureReference) CloseCursor

func (ppr *ProcedureReference) CloseCursor(ctx *sql.Context, id int, name string) error

CloseCursor closes the designated cursor.

func (*ProcedureReference) FetchCursor

func (ppr *ProcedureReference) FetchCursor(ctx *sql.Context, id int, name string) (sql.Row, sql.Schema, error)

FetchCursor returns the next row from the designated cursor.

func (*ProcedureReference) GetHandler

func (ppr *ProcedureReference) GetHandler(id int) (bool, sql.Node, error)

GetHandler returns a boolean indicating if the handler represents an EXIT handler, and a sql.Node containing the logic to execute for this handler. Returns error if an invalid ID is given.

func (*ProcedureReference) GetVariableType

func (ppr *ProcedureReference) GetVariableType(id int) sql.Type

GetVariableType returns the type of the given parameter. Returns the NULL type if the type cannot be found.

func (*ProcedureReference) GetVariableValue

func (ppr *ProcedureReference) GetVariableValue(id int, name string) (interface{}, error)

GetVariableValue returns the value of the given parameter.

func (*ProcedureReference) InitializeCursor

func (ppr *ProcedureReference) InitializeCursor(id int, name string, selectStmt sql.Node)

InitializeCursor sets the initial state for the cursor.

func (*ProcedureReference) InitializeHandler

func (ppr *ProcedureReference) InitializeHandler(id int, stmt sql.Node, returnsExitError bool)

InitializeHandler sets the given handler's statement.

func (*ProcedureReference) InitializeVariable

func (ppr *ProcedureReference) InitializeVariable(id int, name string, sqlType sql.Type, val interface{}) error

InitializeVariable sets the initial value for the variable.

func (*ProcedureReference) OpenCursor

func (ppr *ProcedureReference) OpenCursor(ctx *sql.Context, id int, name string, row sql.Row) error

OpenCursor sets the designated cursor to open.

func (*ProcedureReference) SetVariable

func (ppr *ProcedureReference) SetVariable(id int, name string, val interface{}, valType sql.Type) error

SetVariable updates the value of the given parameter.

func (*ProcedureReference) VariableHasBeenSet

func (ppr *ProcedureReference) VariableHasBeenSet(id int) bool

VariableHasBeenSet returns whether the parameter has had its value altered from the initial value.

type Regexp

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

Regexp is a comparison that checks an expression matches a regexp.

func NewRegexp

func NewRegexp(left sql.Expression, right sql.Expression) *Regexp

NewRegexp creates a new Regexp expression.

func (*Regexp) Compare

func (c *Regexp) Compare(ctx *sql.Context, row sql.Row) (int, error)

Compare the two given values using the types of the expressions in the comparison. Since both types should be equal, it does not matter which type is used, but for reference, the left type is always used.

func (*Regexp) DebugString

func (re *Regexp) DebugString() string

func (*Regexp) Eval

func (re *Regexp) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Regexp) Left

func (c *Regexp) Left() sql.Expression

Left implements Comparer interface

func (*Regexp) Right

func (c *Regexp) Right() sql.Expression

Right implements Comparer interface

func (*Regexp) String

func (re *Regexp) String() string

func (*Regexp) Type

func (*Regexp) Type() sql.Type

Type implements the Expression interface.

func (*Regexp) WithChildren

func (re *Regexp) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type SetField

type SetField struct {
	BinaryExpression
}

SetField updates the value of a field or a system variable

func (*SetField) DebugString

func (s *SetField) DebugString() string

func (*SetField) Eval

func (s *SetField) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface. Returns a copy of the given row with an updated value.

func (*SetField) String

func (s *SetField) String() string

func (*SetField) Type

func (s *SetField) Type() sql.Type

Type implements the Expression interface.

func (*SetField) WithChildren

func (s *SetField) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Sorter

type Sorter struct {
	SortFields []sql.SortField
	Rows       []sql.Row
	LastError  error
	Ctx        *sql.Context
}

Sorter is a sorter implementation for Row slices using SortFields for the comparison

func (*Sorter) Len

func (s *Sorter) Len() int

func (*Sorter) Less

func (s *Sorter) Less(i, j int) bool

func (*Sorter) Swap

func (s *Sorter) Swap(i, j int)

type Sorter2

type Sorter2 struct {
	SortFields []sql.SortField
	Rows       []sql.Row2
	LastError  error
	Ctx        *sql.Context
}

Sorter2 is a version of Sorter that operates on Row2

func (*Sorter2) Len

func (s *Sorter2) Len() int

func (*Sorter2) Less

func (s *Sorter2) Less(i, j int) bool

func (*Sorter2) Swap

func (s *Sorter2) Swap(i, j int)

type Star

type Star struct {
	Table string
}

Star represents the selection of all available fields. This is just a placeholder node, it will not actually be evaluated but converted to a series of GetFields when the query is analyzed.

func NewQualifiedStar

func NewQualifiedStar(table string) *Star

NewQualifiedStar returns a new star expression only for a specific table.

func NewStar

func NewStar() *Star

NewStar returns a new Star expression.

func (*Star) Children

func (*Star) Children() []sql.Expression

Children implements the Expression interface.

func (*Star) Eval

func (*Star) Eval(ctx *sql.Context, r sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Star) IsNullable

func (*Star) IsNullable() bool

IsNullable implements the Expression interface.

func (*Star) Resolved

func (*Star) Resolved() bool

Resolved implements the Expression interface.

func (*Star) String

func (s *Star) String() string

func (*Star) Type

func (*Star) Type() sql.Type

Type implements the Expression interface.

func (*Star) WithChildren

func (s *Star) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type SystemVar

type SystemVar struct {
	Name  string
	Scope sql.SystemVariableScope
}

SystemVar is an expression that returns the value of a system variable. It's also used as the expression on the left hand side of a SET statement for a system variable.

func NewSystemVar

func NewSystemVar(name string, scope sql.SystemVariableScope) *SystemVar

NewSystemVar creates a new SystemVar expression.

func (*SystemVar) Children

func (v *SystemVar) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*SystemVar) Eval

func (v *SystemVar) Eval(ctx *sql.Context, _ sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*SystemVar) IsNullable

func (v *SystemVar) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*SystemVar) Resolved

func (v *SystemVar) Resolved() bool

Resolved implements the sql.Expression interface.

func (*SystemVar) String

func (v *SystemVar) String() string

String implements the sql.Expression interface.

func (*SystemVar) Type

func (v *SystemVar) Type() sql.Type

Type implements the sql.Expression interface.

func (*SystemVar) WithChildren

func (v *SystemVar) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type TimeDelta

type TimeDelta struct {
	Years        int64
	Months       int64
	Days         int64
	Hours        int64
	Minutes      int64
	Seconds      int64
	Microseconds int64
}

TimeDelta is the difference between a time and another time.

func (TimeDelta) Add

func (td TimeDelta) Add(t time.Time) time.Time

Add returns the given time plus the time delta.

func (TimeDelta) Sub

func (td TimeDelta) Sub(t time.Time) time.Time

Sub returns the given time minus the time delta.

type TopRowsHeap

type TopRowsHeap struct {
	Sorter
}

TopRowsHeap implements heap.Interface based on Sorter. It inverts the Less() function so that it can be used to implement TopN. heap.Push() rows into it, and if Len() > MAX; heap.Pop() the current min row. Then, at the end of seeing all the rows, call Rows(). Rows() will return the rows which come back from heap.Pop() in reverse order, correctly restoring the order for the TopN elements.

func (*TopRowsHeap) Less

func (h *TopRowsHeap) Less(i, j int) bool

func (*TopRowsHeap) Pop

func (h *TopRowsHeap) Pop() interface{}

func (*TopRowsHeap) Push

func (h *TopRowsHeap) Push(x interface{})

func (*TopRowsHeap) Rows

func (h *TopRowsHeap) Rows() ([]sql.Row, error)

type Tuple

type Tuple []sql.Expression

Tuple is a fixed-size collection of expressions. A tuple of size 1 is treated as the expression itself.

func NewTuple

func NewTuple(exprs ...sql.Expression) Tuple

NewTuple creates a new Tuple expression.

func (Tuple) Children

func (t Tuple) Children() []sql.Expression

Children implements the Expression interface.

func (Tuple) DebugString

func (t Tuple) DebugString() string

func (Tuple) Eval

func (t Tuple) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (Tuple) IsNullable

func (t Tuple) IsNullable() bool

IsNullable implements the Expression interface.

func (Tuple) Resolved

func (t Tuple) Resolved() bool

Resolved implements the Expression interface.

func (Tuple) String

func (t Tuple) String() string

func (Tuple) Type

func (t Tuple) Type() sql.Type

Type implements the Expression interface.

func (Tuple) WithChildren

func (t Tuple) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type UnaryExpression

type UnaryExpression struct {
	Child sql.Expression
}

UnaryExpression is an expression that has only one children.

func (*UnaryExpression) Children

func (p *UnaryExpression) Children() []sql.Expression

Children implements the Expression interface.

func (*UnaryExpression) IsNullable

func (p *UnaryExpression) IsNullable() bool

IsNullable returns whether the expression can be null.

func (*UnaryExpression) Resolved

func (p *UnaryExpression) Resolved() bool

Resolved implements the Expression interface.

type UnaryMinus

type UnaryMinus struct {
	UnaryExpression
}

UnaryMinus is an unary minus operator.

func NewUnaryMinus

func NewUnaryMinus(child sql.Expression) *UnaryMinus

NewUnaryMinus creates a new UnaryMinus expression node.

func (*UnaryMinus) Eval

func (e *UnaryMinus) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*UnaryMinus) String

func (e *UnaryMinus) String() string

func (*UnaryMinus) Type

func (e *UnaryMinus) Type() sql.Type

Type implements the sql.Expression interface.

func (*UnaryMinus) WithChildren

func (e *UnaryMinus) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type UnresolvedColumn

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

UnresolvedColumn is an expression of a column that is not yet resolved. This is a placeholder node, so its methods Type, IsNullable and Eval are not supposed to be called.

func NewUnresolvedColumn

func NewUnresolvedColumn(name string) *UnresolvedColumn

NewUnresolvedColumn creates a new UnresolvedColumn expression.

func NewUnresolvedQualifiedColumn

func NewUnresolvedQualifiedColumn(table, name string) *UnresolvedColumn

NewUnresolvedQualifiedColumn creates a new UnresolvedColumn expression with a table qualifier.

func (*UnresolvedColumn) Children

func (*UnresolvedColumn) Children() []sql.Expression

Children implements the Expression interface.

func (*UnresolvedColumn) Eval

func (*UnresolvedColumn) Eval(ctx *sql.Context, r sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*UnresolvedColumn) Eval2

func (uc *UnresolvedColumn) Eval2(ctx *sql.Context, row sql.Row2) (sql.Value, error)

func (*UnresolvedColumn) IsNullable

func (*UnresolvedColumn) IsNullable() bool

IsNullable implements the Expression interface.

func (*UnresolvedColumn) Name

func (uc *UnresolvedColumn) Name() string

Name implements the Nameable interface.

func (*UnresolvedColumn) Resolved

func (*UnresolvedColumn) Resolved() bool

Resolved implements the Expression interface.

func (*UnresolvedColumn) String

func (uc *UnresolvedColumn) String() string

func (*UnresolvedColumn) Table

func (uc *UnresolvedColumn) Table() string

Table returns the table name.

func (*UnresolvedColumn) Type

func (*UnresolvedColumn) Type() sql.Type

Type implements the Expression interface.

func (*UnresolvedColumn) Type2

func (uc *UnresolvedColumn) Type2() sql.Type2

func (*UnresolvedColumn) WithChildren

func (uc *UnresolvedColumn) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type UnresolvedFunction

type UnresolvedFunction struct {

	// IsAggregate or not.
	IsAggregate bool
	// Window is the window for this function, if present
	Window *sql.WindowDefinition
	// Children of the expression.
	Arguments []sql.Expression
	// contains filtered or unexported fields
}

UnresolvedFunction represents a function that is not yet resolved. This is a placeholder node, so its methods Type, IsNullable and Eval are not supposed to be called.

func NewUnresolvedFunction

func NewUnresolvedFunction(
	name string,
	agg bool,
	window *sql.WindowDefinition,
	arguments ...sql.Expression,
) *UnresolvedFunction

NewUnresolvedFunction creates a new UnresolvedFunction expression.

func (*UnresolvedFunction) Children

func (uf *UnresolvedFunction) Children() []sql.Expression

Children implements the Expression interface.

func (*UnresolvedFunction) DebugString

func (uf *UnresolvedFunction) DebugString() string

func (*UnresolvedFunction) Eval

func (*UnresolvedFunction) Eval(ctx *sql.Context, r sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*UnresolvedFunction) IsNullable

func (*UnresolvedFunction) IsNullable() bool

IsNullable implements the Expression interface.

func (*UnresolvedFunction) Name

func (uf *UnresolvedFunction) Name() string

Name implements the Nameable interface.

func (*UnresolvedFunction) Resolved

func (*UnresolvedFunction) Resolved() bool

Resolved implements the Expression interface.

func (*UnresolvedFunction) String

func (uf *UnresolvedFunction) String() string

func (*UnresolvedFunction) Type

func (*UnresolvedFunction) Type() sql.Type

Type implements the Expression interface.

func (*UnresolvedFunction) WithChildren

func (uf *UnresolvedFunction) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

func (*UnresolvedFunction) WithWindow

WithWindow implements the Expression interface.

type UnresolvedProcedureParam

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

UnresolvedProcedureParam represents an unresolved parameter of a stored procedure or stored function.

func NewUnresolvedProcedureParam

func NewUnresolvedProcedureParam(name string) *UnresolvedProcedureParam

NewUnresolvedProcedureParam creates a new UnresolvedProcedureParam expression.

func (*UnresolvedProcedureParam) Children

func (*UnresolvedProcedureParam) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*UnresolvedProcedureParam) Eval

func (upp *UnresolvedProcedureParam) Eval(ctx *sql.Context, r sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*UnresolvedProcedureParam) IsNullable

func (*UnresolvedProcedureParam) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*UnresolvedProcedureParam) Name

func (upp *UnresolvedProcedureParam) Name() string

Name implements the Nameable interface.

func (*UnresolvedProcedureParam) Resolved

func (*UnresolvedProcedureParam) Resolved() bool

Resolved implements the sql.Expression interface.

func (*UnresolvedProcedureParam) String

func (upp *UnresolvedProcedureParam) String() string

String implements the sql.Expression interface.

func (*UnresolvedProcedureParam) Type

Type implements the sql.Expression interface.

func (*UnresolvedProcedureParam) WithChildren

func (upp *UnresolvedProcedureParam) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the sql.Expression interface.

type UnresolvedTableFunction

type UnresolvedTableFunction struct {
	Arguments []sql.Expression
	// contains filtered or unexported fields
}

UnresolvedTableFunction represents a table function that is not yet resolved. This is a placeholder node, so methods such as Schema, RowIter, etc, are not intended to be used.

func NewUnresolvedTableFunction

func NewUnresolvedTableFunction(name string, arguments []sql.Expression) *UnresolvedTableFunction

NewUnresolvedTableFunction creates a new UnresolvedTableFunction node for a sql plan.

func (UnresolvedTableFunction) CheckPrivileges

func (utf UnresolvedTableFunction) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool

CheckPrivileges implements the Node interface

func (*UnresolvedTableFunction) Children

func (utf *UnresolvedTableFunction) Children() []sql.Node

Children implements the Node interface

func (*UnresolvedTableFunction) Database

func (utf *UnresolvedTableFunction) Database() sql.Database

Database implements the Databaser interface

func (*UnresolvedTableFunction) Expressions

func (utf *UnresolvedTableFunction) Expressions() []sql.Expression

Expressions implements the Expressioner interface

func (*UnresolvedTableFunction) Name

func (utf *UnresolvedTableFunction) Name() string

Name implements the TableFunction interface

func (*UnresolvedTableFunction) NewInstance

func (utf *UnresolvedTableFunction) NewInstance(_ *sql.Context, _ sql.Database, _ []sql.Expression) (sql.Node, error)

NewInstance implements the TableFunction interface

func (*UnresolvedTableFunction) Resolved

func (utf *UnresolvedTableFunction) Resolved() bool

Resolved implements the Resolvable interface

func (*UnresolvedTableFunction) RowIter

func (utf *UnresolvedTableFunction) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error)

RowIter implements the Node interface

func (*UnresolvedTableFunction) Schema

func (utf *UnresolvedTableFunction) Schema() sql.Schema

Schema implements the Node interface

func (*UnresolvedTableFunction) String

func (utf *UnresolvedTableFunction) String() string

String implements the Stringer interface

func (*UnresolvedTableFunction) WithChildren

func (utf *UnresolvedTableFunction) WithChildren(node ...sql.Node) (sql.Node, error)

WithChildren implements the Node interface

func (*UnresolvedTableFunction) WithDatabase

func (utf *UnresolvedTableFunction) WithDatabase(database sql.Database) (sql.Node, error)

WithDatabase implements the Databaser interface

func (*UnresolvedTableFunction) WithExpressions

func (utf *UnresolvedTableFunction) WithExpressions(expression ...sql.Expression) (sql.Node, error)

WithExpressions implements the Expressioner interface

type UserVar

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

UserVar is an expression that returns the value of a user variable. It's also used as the expression on the left hand side of a SET statement for a user var.

func NewUserVar

func NewUserVar(name string) *UserVar

NewUserVar creates a UserVar with a name, but no type information, for use as the left-hand value in a SetField assignment Expression. This method should not be used when the user variable is being used as a value, since the correct type information will not be available.

func NewUserVarWithType

func NewUserVarWithType(name string, t sql.Type) *UserVar

NewUserVarWithType creates a UserVar with its type resolved, so that it can be used as a value in other expressions.

func (*UserVar) Children

func (v *UserVar) Children() []sql.Expression

Children implements the sql.Expression interface.

func (*UserVar) Eval

func (v *UserVar) Eval(ctx *sql.Context, _ sql.Row) (interface{}, error)

Eval implements the sql.Expression interface.

func (*UserVar) IsNullable

func (v *UserVar) IsNullable() bool

IsNullable implements the sql.Expression interface.

func (*UserVar) Resolved

func (v *UserVar) Resolved() bool

Resolved implements the sql.Expression interface.

func (*UserVar) String

func (v *UserVar) String() string

String implements the sql.Expression interface.

func (*UserVar) Type

func (v *UserVar) Type() sql.Type

Type implements the sql.Expression interface.

func (*UserVar) WithChildren

func (v *UserVar) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

type Wrapper

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

Wrapper simply acts as a wrapper for another expression. If a nil expression is wrapped, then the wrapper functions as a guard against functions that expect non-nil expressions.

func WrapExpression

func WrapExpression(expr sql.Expression) *Wrapper

WrapExpression takes in an expression and wraps it, returning the resulting Wrapper expression. Useful for when an expression is nil.

func (*Wrapper) Children

func (w *Wrapper) Children() []sql.Expression

Children implements sql.Expression

func (*Wrapper) Eval

func (w *Wrapper) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements sql.Expression

func (*Wrapper) IsNullable

func (w *Wrapper) IsNullable() bool

IsNullable implements sql.Expression

func (*Wrapper) Resolved

func (w *Wrapper) Resolved() bool

Resolved implements sql.Expression

func (*Wrapper) String

func (w *Wrapper) String() string

String implements sql.Expression

func (*Wrapper) Type

func (w *Wrapper) Type() sql.Type

Type implements sql.Expression

func (*Wrapper) Unwrap

func (w *Wrapper) Unwrap() sql.Expression

Unwrap returns the wrapped expression, or nil if no expression was wrapped.

func (*Wrapper) WithChildren

func (w *Wrapper) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements sql.Expression

type Xor

type Xor struct {
	BinaryExpression
}

Xor checks whether only one of the two given expressions is true.

func (*Xor) DebugString

func (x *Xor) DebugString() string

func (*Xor) Eval

func (x *Xor) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the Expression interface.

func (*Xor) String

func (x *Xor) String() string

func (*Xor) Type

func (*Xor) Type() sql.Type

Type implements the Expression interface.

func (*Xor) WithChildren

func (x *Xor) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the Expression interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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