Documentation ¶
Index ¶
- Constants
- Variables
- func AsString(n NodeFormatter) string
- func AsStringWithFlags(n NodeFormatter, f FmtFlags) string
- func ContainsVars(expr Expr) bool
- func FindEqualComparisonFunction(leftType, rightType Type) (func(*EvalContext, Datum, Datum) (DBool, error), bool)
- func FormatNode(buf *bytes.Buffer, f FmtFlags, n NodeFormatter)
- func IsNumericOne(expr TypedExpr) bool
- func IsNumericZero(expr TypedExpr) bool
- func ReNormalizeName(name string) string
- func SimilarEscape(pattern string) string
- func ValidateRestartCheckpoint(savepoint string) error
- func WalkExprConst(v Visitor, expr Expr)
- type AggregateFunc
- type AliasClause
- type AliasedTableExpr
- type AllColumnsSelector
- func (expr *AllColumnsSelector) Eval(ctx *EvalContext) (Datum, error)
- func (a *AllColumnsSelector) Format(buf *bytes.Buffer, f FmtFlags)
- func (a *AllColumnsSelector) NormalizeVarName() (VarName, error)
- func (*AllColumnsSelector) ResolvedType() Type
- func (a *AllColumnsSelector) String() string
- func (expr *AllColumnsSelector) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (a *AllColumnsSelector) Variable()
- func (expr *AllColumnsSelector) Walk(_ Visitor) Expr
- type AllTablesSelector
- type AlterTable
- type AlterTableAddColumn
- type AlterTableAddConstraint
- type AlterTableCmd
- type AlterTableCmds
- type AlterTableDropColumn
- type AlterTableDropConstraint
- type AlterTableDropNotNull
- type AlterTableSetDefault
- type AlterTableValidateConstraint
- type AndExpr
- func (expr *AndExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *AndExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta AndExpr) ResolvedType() Type
- func (node *AndExpr) String() string
- func (expr *AndExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *AndExpr) TypedLeft() TypedExpr
- func (node *AndExpr) TypedRight() TypedExpr
- func (expr *AndExpr) Walk(v Visitor) Expr
- type AnnotateTypeExpr
- func (expr *AnnotateTypeExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *AnnotateTypeExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta AnnotateTypeExpr) ResolvedType() Type
- func (node *AnnotateTypeExpr) String() string
- func (expr *AnnotateTypeExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr
- func (expr *AnnotateTypeExpr) Walk(v Visitor) Expr
- type AnyType
- type ArgTypes
- type Array
- func (t *Array) Eval(ctx *EvalContext) (Datum, error)
- func (node *Array) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta Array) ResolvedType() Type
- func (node *Array) String() string
- func (expr *Array) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *Array) Walk(v Visitor) Expr
- type ArraySubscript
- type AsOfClause
- type BeginTransaction
- type BinOp
- type BinaryExpr
- func (expr *BinaryExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *BinaryExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta BinaryExpr) ResolvedType() Type
- func (node *BinaryExpr) String() string
- func (expr *BinaryExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *BinaryExpr) TypedLeft() TypedExpr
- func (node *BinaryExpr) TypedRight() TypedExpr
- func (expr *BinaryExpr) Walk(v Visitor) Expr
- type BinaryOperator
- type BoolColType
- type Builtin
- type BytesColType
- type CaseExpr
- func (expr *CaseExpr) CopyNode() *CaseExpr
- func (expr *CaseExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *CaseExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta CaseExpr) ResolvedType() Type
- func (node *CaseExpr) String() string
- func (expr *CaseExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *CaseExpr) Walk(v Visitor) Expr
- type CastExpr
- func (expr *CastExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *CastExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta CastExpr) ResolvedType() Type
- func (node *CastExpr) String() string
- func (expr *CastExpr) TypeCheck(ctx *SemaContext, _ Type) (TypedExpr, error)
- func (expr *CastExpr) Walk(v Visitor) Expr
- type CheckConstraintTableDef
- type CmpOp
- type CoalesceExpr
- func (expr *CoalesceExpr) CopyNode() *CoalesceExpr
- func (expr *CoalesceExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *CoalesceExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta CoalesceExpr) ResolvedType() Type
- func (node *CoalesceExpr) String() string
- func (expr *CoalesceExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *CoalesceExpr) TypedExprAt(idx int) TypedExpr
- func (expr *CoalesceExpr) Walk(v Visitor) Expr
- type CollateExpr
- func (expr *CollateExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *CollateExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta CollateExpr) ResolvedType() Type
- func (node *CollateExpr) String() string
- func (expr *CollateExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *CollateExpr) Walk(v Visitor) Expr
- type CollationEnvironment
- type ColumnCheckConstraint
- type ColumnDefault
- type ColumnFKConstraint
- type ColumnFamilyConstraint
- type ColumnItem
- func (c *ColumnItem) Column() string
- func (expr *ColumnItem) Eval(ctx *EvalContext) (Datum, error)
- func (c *ColumnItem) Format(buf *bytes.Buffer, f FmtFlags)
- func (c *ColumnItem) NormalizeVarName() (VarName, error)
- func (c *ColumnItem) ResolvedType() Type
- func (c *ColumnItem) String() string
- func (expr *ColumnItem) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (c *ColumnItem) Variable()
- func (expr *ColumnItem) Walk(_ Visitor) Expr
- type ColumnMutationCmd
- type ColumnQualification
- type ColumnTableDef
- type ColumnTableDefCheckExpr
- type ColumnType
- type CommitTransaction
- type ComparisonExpr
- func (expr *ComparisonExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *ComparisonExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (node *ComparisonExpr) IsMixedTypeComparison() bool
- func (ta ComparisonExpr) ResolvedType() Type
- func (node *ComparisonExpr) String() string
- func (expr *ComparisonExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *ComparisonExpr) TypedLeft() TypedExpr
- func (node *ComparisonExpr) TypedRight() TypedExpr
- func (expr *ComparisonExpr) Walk(v Visitor) Expr
- type ComparisonOperator
- type Constant
- type ConstraintTableDef
- type ContainsWindowVisitor
- type CopyFrom
- type CreateDatabase
- type CreateIndex
- type CreateTable
- type CreateUser
- type CreateView
- type DArray
- func (d *DArray) Compare(other Datum) int
- func (t *DArray) Eval(_ *EvalContext) (Datum, error)
- func (d *DArray) Format(buf *bytes.Buffer, f FmtFlags)
- func (d *DArray) HasNext() bool
- func (d *DArray) HasPrev() bool
- func (*DArray) IsMax() bool
- func (*DArray) IsMin() bool
- func (d *DArray) Len() int
- func (d *DArray) Less(i, j int) bool
- func (d *DArray) Next() Datum
- func (d *DArray) Prev() Datum
- func (d *DArray) ResolvedType() Type
- func (d *DArray) Size() uintptr
- func (node *DArray) String() string
- func (d *DArray) Swap(i, j int)
- func (d *DArray) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DArray) Walk(_ Visitor) Expr
- type DBool
- func (d *DBool) Compare(other Datum) int
- func (t *DBool) Eval(_ *EvalContext) (Datum, error)
- func (d *DBool) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DBool) HasNext() bool
- func (*DBool) HasPrev() bool
- func (d *DBool) IsMax() bool
- func (d *DBool) IsMin() bool
- func (*DBool) Next() Datum
- func (*DBool) Prev() Datum
- func (*DBool) ResolvedType() Type
- func (d *DBool) Size() uintptr
- func (node *DBool) String() string
- func (d *DBool) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DBool) Walk(_ Visitor) Expr
- type DBytes
- func (d *DBytes) Compare(other Datum) int
- func (t *DBytes) Eval(_ *EvalContext) (Datum, error)
- func (d *DBytes) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DBytes) HasNext() bool
- func (*DBytes) HasPrev() bool
- func (*DBytes) IsMax() bool
- func (d *DBytes) IsMin() bool
- func (d *DBytes) Next() Datum
- func (d *DBytes) Prev() Datum
- func (*DBytes) ResolvedType() Type
- func (d *DBytes) Size() uintptr
- func (node *DBytes) String() string
- func (d *DBytes) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DBytes) Walk(_ Visitor) Expr
- type DCollatedString
- func (d *DCollatedString) Compare(other Datum) int
- func (t *DCollatedString) Eval(_ *EvalContext) (Datum, error)
- func (d *DCollatedString) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DCollatedString) HasNext() bool
- func (*DCollatedString) HasPrev() bool
- func (*DCollatedString) IsMax() bool
- func (d *DCollatedString) IsMin() bool
- func (d *DCollatedString) Next() Datum
- func (d *DCollatedString) Prev() Datum
- func (d *DCollatedString) ResolvedType() Type
- func (d *DCollatedString) Size() uintptr
- func (node *DCollatedString) String() string
- func (d *DCollatedString) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DCollatedString) Walk(_ Visitor) Expr
- type DDate
- func (d *DDate) Compare(other Datum) int
- func (t *DDate) Eval(_ *EvalContext) (Datum, error)
- func (d *DDate) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DDate) HasNext() bool
- func (*DDate) HasPrev() bool
- func (d *DDate) IsMax() bool
- func (d *DDate) IsMin() bool
- func (d *DDate) Next() Datum
- func (d *DDate) Prev() Datum
- func (*DDate) ResolvedType() Type
- func (d *DDate) Size() uintptr
- func (node *DDate) String() string
- func (d *DDate) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DDate) Walk(_ Visitor) Expr
- type DDecimal
- func (d *DDecimal) Compare(other Datum) int
- func (t *DDecimal) Eval(_ *EvalContext) (Datum, error)
- func (d *DDecimal) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DDecimal) HasNext() bool
- func (*DDecimal) HasPrev() bool
- func (*DDecimal) IsMax() bool
- func (*DDecimal) IsMin() bool
- func (d *DDecimal) Next() Datum
- func (d *DDecimal) Prev() Datum
- func (*DDecimal) ResolvedType() Type
- func (d *DDecimal) Size() uintptr
- func (node *DDecimal) String() string
- func (d *DDecimal) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DDecimal) Walk(_ Visitor) Expr
- type DFloat
- func (d *DFloat) Compare(other Datum) int
- func (t *DFloat) Eval(_ *EvalContext) (Datum, error)
- func (d *DFloat) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DFloat) HasNext() bool
- func (*DFloat) HasPrev() bool
- func (d *DFloat) IsMax() bool
- func (d *DFloat) IsMin() bool
- func (d *DFloat) Next() Datum
- func (d *DFloat) Prev() Datum
- func (*DFloat) ResolvedType() Type
- func (d *DFloat) Size() uintptr
- func (node *DFloat) String() string
- func (d *DFloat) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DFloat) Walk(_ Visitor) Expr
- type DInt
- func (d *DInt) Compare(other Datum) int
- func (t *DInt) Eval(_ *EvalContext) (Datum, error)
- func (d *DInt) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DInt) HasNext() bool
- func (*DInt) HasPrev() bool
- func (d *DInt) IsMax() bool
- func (d *DInt) IsMin() bool
- func (d *DInt) Next() Datum
- func (d *DInt) Prev() Datum
- func (*DInt) ResolvedType() Type
- func (d *DInt) Size() uintptr
- func (node *DInt) String() string
- func (d *DInt) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DInt) Walk(_ Visitor) Expr
- type DInterval
- func (d *DInterval) Compare(other Datum) int
- func (t *DInterval) Eval(_ *EvalContext) (Datum, error)
- func (d *DInterval) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DInterval) HasNext() bool
- func (*DInterval) HasPrev() bool
- func (d *DInterval) IsMax() bool
- func (d *DInterval) IsMin() bool
- func (d *DInterval) Next() Datum
- func (d *DInterval) Prev() Datum
- func (*DInterval) ResolvedType() Type
- func (d *DInterval) Size() uintptr
- func (node *DInterval) String() string
- func (d *DInterval) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (d *DInterval) ValueAsString() string
- func (expr *DInterval) Walk(_ Visitor) Expr
- type DString
- func (d *DString) Compare(other Datum) int
- func (t *DString) Eval(_ *EvalContext) (Datum, error)
- func (d *DString) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DString) HasNext() bool
- func (*DString) HasPrev() bool
- func (*DString) IsMax() bool
- func (d *DString) IsMin() bool
- func (d *DString) Next() Datum
- func (d *DString) Prev() Datum
- func (*DString) ResolvedType() Type
- func (d *DString) Size() uintptr
- func (node *DString) String() string
- func (d *DString) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DString) Walk(_ Visitor) Expr
- type DTimestamp
- func (d *DTimestamp) Compare(other Datum) int
- func (t *DTimestamp) Eval(_ *EvalContext) (Datum, error)
- func (d *DTimestamp) Format(buf *bytes.Buffer, f FmtFlags)
- func (*DTimestamp) HasNext() bool
- func (*DTimestamp) HasPrev() bool
- func (d *DTimestamp) IsMax() bool
- func (d *DTimestamp) IsMin() bool
- func (d *DTimestamp) Next() Datum
- func (d *DTimestamp) Prev() Datum
- func (*DTimestamp) ResolvedType() Type
- func (d *DTimestamp) Size() uintptr
- func (node *DTimestamp) String() string
- func (d *DTimestamp) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DTimestamp) Walk(_ Visitor) Expr
- type DTimestampTZ
- func (d *DTimestampTZ) Compare(other Datum) int
- func (t *DTimestampTZ) Eval(_ *EvalContext) (Datum, error)
- func (d *DTimestampTZ) Format(buf *bytes.Buffer, f FmtFlags)
- func (d *DTimestampTZ) HasNext() bool
- func (d *DTimestampTZ) HasPrev() bool
- func (d *DTimestampTZ) IsMax() bool
- func (d *DTimestampTZ) IsMin() bool
- func (d *DTimestampTZ) Next() Datum
- func (d *DTimestampTZ) Prev() Datum
- func (*DTimestampTZ) ResolvedType() Type
- func (d *DTimestampTZ) Size() uintptr
- func (node *DTimestampTZ) String() string
- func (d *DTimestampTZ) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DTimestampTZ) Walk(_ Visitor) Expr
- type DTuple
- func (d *DTuple) Compare(other Datum) int
- func (t *DTuple) Eval(_ *EvalContext) (Datum, error)
- func (d *DTuple) Format(buf *bytes.Buffer, f FmtFlags)
- func (d *DTuple) HasNext() bool
- func (d *DTuple) HasPrev() bool
- func (*DTuple) IsMax() bool
- func (*DTuple) IsMin() bool
- func (d *DTuple) Len() int
- func (d *DTuple) Less(i, j int) bool
- func (d *DTuple) Next() Datum
- func (d *DTuple) Normalize()
- func (d *DTuple) Prev() Datum
- func (d *DTuple) ResolvedType() Type
- func (d *DTuple) Size() uintptr
- func (d *DTuple) SortedDifference(other *DTuple) *DTuple
- func (node *DTuple) String() string
- func (d *DTuple) Swap(i, j int)
- func (d *DTuple) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr *DTuple) Walk(_ Visitor) Expr
- type DateColType
- type Datum
- type Deallocate
- type DecimalColType
- type DefaultVal
- func (expr DefaultVal) Eval(_ *EvalContext) (Datum, error)
- func (node DefaultVal) Format(buf *bytes.Buffer, f FmtFlags)
- func (DefaultVal) ResolvedType() Type
- func (node DefaultVal) String() string
- func (expr DefaultVal) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (expr DefaultVal) Walk(_ Visitor) Expr
- type Delete
- type Direction
- type DropBehavior
- type DropDatabase
- type DropIndex
- type DropTable
- type DropView
- type EvalContext
- func (ctx *EvalContext) GetClusterTimestamp() *DDecimal
- func (ctx *EvalContext) GetLocation() *time.Location
- func (ctx *EvalContext) GetStmtTimestamp() time.Time
- func (ctx *EvalContext) GetTxnTimestamp(precision time.Duration) *DTimestampTZ
- func (ctx *EvalContext) GetTxnTimestampNoZone(precision time.Duration) *DTimestamp
- func (ctx *EvalContext) NormalizeExpr(typedExpr TypedExpr) (TypedExpr, error)
- func (ctx *EvalContext) SetClusterTimestamp(ts hlc.Timestamp)
- func (ctx *EvalContext) SetStmtTimestamp(ts time.Time)
- func (ctx *EvalContext) SetTxnTimestamp(ts time.Time)
- type Execute
- type ExistsExpr
- func (t *ExistsExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *ExistsExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta ExistsExpr) ResolvedType() Type
- func (node *ExistsExpr) String() string
- func (expr *ExistsExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *ExistsExpr) Walk(v Visitor) Expr
- type Explain
- type Expr
- type Exprs
- type FamilyTableDef
- type FloatColType
- type FmtFlags
- type ForeignKeyConstraintTableDef
- type From
- type FuncExpr
- func (expr *FuncExpr) CopyNode() *FuncExpr
- func (expr *FuncExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *FuncExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (node *FuncExpr) GetAggregateConstructor() func() AggregateFunc
- func (node *FuncExpr) GetWindowConstructor() func() WindowFunc
- func (node *FuncExpr) IsImpure() bool
- func (node *FuncExpr) IsWindowFunctionApplication() bool
- func (ta FuncExpr) ResolvedType() Type
- func (node *FuncExpr) String() string
- func (expr *FuncExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *FuncExpr) Walk(v Visitor) Expr
- type FunctionClass
- type FunctionDefinition
- type FunctionReference
- type Grant
- type GroupBy
- type Help
- type IfExpr
- func (expr *IfExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *IfExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta IfExpr) ResolvedType() Type
- func (node *IfExpr) String() string
- func (expr *IfExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *IfExpr) TypedCondExpr() TypedExpr
- func (node *IfExpr) TypedElseExpr() TypedExpr
- func (node *IfExpr) TypedTrueExpr() TypedExpr
- func (expr *IfExpr) Walk(v Visitor) Expr
- type IndexElem
- type IndexElemList
- type IndexHints
- type IndexTableDef
- type IndexedRow
- type IndexedVar
- func (v *IndexedVar) Eval(ctx *EvalContext) (Datum, error)
- func (v *IndexedVar) Format(buf *bytes.Buffer, f FmtFlags)
- func (v *IndexedVar) ResolvedType() Type
- func (node *IndexedVar) String() string
- func (v *IndexedVar) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (*IndexedVar) Variable()
- func (v *IndexedVar) Walk(_ Visitor) Expr
- type IndexedVarContainer
- type IndexedVarHelper
- type IndirectionExpr
- func (expr *IndirectionExpr) CopyNode() *IndirectionExpr
- func (expr *IndirectionExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *IndirectionExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta IndirectionExpr) ResolvedType() Type
- func (node *IndirectionExpr) String() string
- func (expr *IndirectionExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *IndirectionExpr) Walk(v Visitor) Expr
- type Insert
- func (stmt *Insert) CopyNode() *Insert
- func (node *Insert) DefaultValues() bool
- func (node *Insert) Format(buf *bytes.Buffer, f FmtFlags)
- func (*Insert) StatementTag() string
- func (n *Insert) StatementType() StatementType
- func (n *Insert) String() string
- func (stmt *Insert) WalkStmt(v Visitor) Statement
- type IntColType
- type InterleaveDef
- type IntervalColType
- type IsAggregateVisitor
- type IsOfTypeExpr
- func (expr *IsOfTypeExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *IsOfTypeExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta IsOfTypeExpr) ResolvedType() Type
- func (node *IsOfTypeExpr) String() string
- func (expr *IsOfTypeExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *IsOfTypeExpr) Walk(v Visitor) Expr
- type IsolationLevel
- type JoinCond
- type JoinTableExpr
- type Limit
- type MaxAggregate
- type MinAggregate
- type Name
- type NameList
- type NamePart
- type NameParts
- type NamedArgTypes
- type NamedColumnQualification
- type NaturalJoinCond
- type NodeFormatter
- type NormalizableTableName
- func (nt NormalizableTableName) Format(buf *bytes.Buffer, f FmtFlags)
- func (nt *NormalizableTableName) Normalize() (*TableName, error)
- func (nt *NormalizableTableName) NormalizeWithDatabaseName(database string) (*TableName, error)
- func (nt NormalizableTableName) String() string
- func (nt *NormalizableTableName) TableName() *TableName
- type NotExpr
- func (expr *NotExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *NotExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta NotExpr) ResolvedType() Type
- func (node *NotExpr) String() string
- func (expr *NotExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *NotExpr) TypedInnerExpr() TypedExpr
- func (expr *NotExpr) Walk(v Visitor) Expr
- type NotNullConstraint
- type NullConstraint
- type NullIfExpr
- func (expr *NullIfExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *NullIfExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta NullIfExpr) ResolvedType() Type
- func (node *NullIfExpr) String() string
- func (expr *NullIfExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *NullIfExpr) Walk(v Visitor) Expr
- type Nullability
- type NumVal
- func (expr *NumVal) AvailableTypes() []Type
- func (expr *NumVal) Format(buf *bytes.Buffer, f FmtFlags)
- func (expr *NumVal) ResolveAsType(ctx *SemaContext, typ Type) (Datum, error)
- func (node *NumVal) String() string
- func (expr *NumVal) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *NumVal) Walk(_ Visitor) Expr
- type OnConflict
- type OnJoinCond
- type OrExpr
- func (expr *OrExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *OrExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta OrExpr) ResolvedType() Type
- func (node *OrExpr) String() string
- func (expr *OrExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *OrExpr) TypedLeft() TypedExpr
- func (node *OrExpr) TypedRight() TypedExpr
- func (expr *OrExpr) Walk(v Visitor) Expr
- type Order
- type OrderBy
- type ParenExpr
- func (expr *ParenExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *ParenExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta ParenExpr) ResolvedType() Type
- func (node *ParenExpr) String() string
- func (expr *ParenExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *ParenExpr) TypedInnerExpr() TypedExpr
- func (expr *ParenExpr) Walk(v Visitor) Expr
- type ParenSelect
- type ParenTableExpr
- type Parser
- func (p *Parser) AggregateInExpr(expr Expr) bool
- func (p *Parser) AssertNoAggregationOrWindowing(expr Expr, op string) error
- func (p *Parser) IsAggregate(n *SelectClause, searchPath []string) bool
- func (p *Parser) NormalizeExpr(ctx *EvalContext, typedExpr TypedExpr) (TypedExpr, error)
- func (p *Parser) Parse(sql string, syntax Syntax) (stmts StatementList, err error)
- func (p *Parser) WindowFuncInExpr(expr Expr) bool
- func (p *Parser) WindowFuncInExprs(exprs []TypedExpr) bool
- type Placeholder
- func (node *Placeholder) Eval(_ *EvalContext) (Datum, error)
- func (node *Placeholder) Format(buf *bytes.Buffer, f FmtFlags)
- func (node *Placeholder) ResolvedType() Type
- func (node *Placeholder) String() string
- func (expr *Placeholder) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (*Placeholder) Variable()
- func (expr *Placeholder) Walk(_ Visitor) Expr
- type PlaceholderInfo
- func (p *PlaceholderInfo) AssertAllAssigned() error
- func (p *PlaceholderInfo) Assign(src *PlaceholderInfo)
- func (p *PlaceholderInfo) Clear()
- func (p *PlaceholderInfo) FillUnassigned()
- func (p *PlaceholderInfo) IsUnresolvedPlaceholder(expr Expr) bool
- func (p *PlaceholderInfo) SetType(name string, typ Type) error
- func (p *PlaceholderInfo) SetTypes(src PlaceholderTypes)
- func (p *PlaceholderInfo) SetValue(name string, val Datum)
- func (p *PlaceholderInfo) Type(name string) (Type, bool)
- func (p *PlaceholderInfo) Value(name string) (Datum, bool)
- type PlaceholderTypes
- type Prepare
- type PrimaryKeyConstraint
- type QueryArguments
- type RangeCond
- func (expr *RangeCond) Eval(_ *EvalContext) (Datum, error)
- func (node *RangeCond) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta RangeCond) ResolvedType() Type
- func (node *RangeCond) String() string
- func (expr *RangeCond) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *RangeCond) TypedFrom() TypedExpr
- func (node *RangeCond) TypedLeft() TypedExpr
- func (node *RangeCond) TypedTo() TypedExpr
- func (expr *RangeCond) Walk(v Visitor) Expr
- type RegexpCache
- type ReleaseSavepoint
- type RenameColumn
- type RenameDatabase
- type RenameIndex
- type RenameTable
- type ResolvableFunctionReference
- type ReturningExprs
- type Revoke
- type RollbackToSavepoint
- type RollbackTransaction
- type Savepoint
- type Scanner
- type Select
- type SelectClause
- func (stmt *SelectClause) CopyNode() *SelectClause
- func (node *SelectClause) Format(buf *bytes.Buffer, f FmtFlags)
- func (*SelectClause) StatementTag() string
- func (*SelectClause) StatementType() StatementType
- func (n *SelectClause) String() string
- func (stmt *SelectClause) WalkStmt(v Visitor) Statement
- type SelectExpr
- type SelectExprs
- type SelectStatement
- type SemaContext
- type Set
- type SetDefaultIsolation
- type SetTimeZone
- type SetTransaction
- type Show
- type ShowColumns
- type ShowConstraints
- type ShowCreateTable
- type ShowCreateView
- type ShowDatabases
- type ShowGrants
- type ShowIndex
- type ShowTables
- type ShowUsers
- type SimpleVisitFn
- type Split
- type StarDatum
- func (*StarDatum) Eval(ctx *EvalContext) (Datum, error)
- func (*StarDatum) Format(buf *bytes.Buffer, f FmtFlags)
- func (*StarDatum) ResolvedType() Type
- func (s *StarDatum) String() string
- func (s *StarDatum) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)
- func (*StarDatum) Variable()
- func (s *StarDatum) Walk(v Visitor) Expr
- type Statement
- type StatementList
- type StatementType
- type StrVal
- func (expr *StrVal) AvailableTypes() []Type
- func (expr *StrVal) Format(buf *bytes.Buffer, f FmtFlags)
- func (expr *StrVal) ResolveAsType(ctx *SemaContext, typ Type) (Datum, error)
- func (node *StrVal) String() string
- func (expr *StrVal) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *StrVal) Walk(_ Visitor) Expr
- type StringColType
- type Subquery
- func (expr *Subquery) Eval(_ *EvalContext) (Datum, error)
- func (node *Subquery) Format(buf *bytes.Buffer, f FmtFlags)
- func (*Subquery) ResolvedType() Type
- func (node *Subquery) String() string
- func (expr *Subquery) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (*Subquery) Variable()
- func (expr *Subquery) Walk(v Visitor) Expr
- type Syntax
- type TCollatedString
- type TPlaceholder
- type TTuple
- type TableDef
- type TableDefs
- type TableExpr
- type TableExprs
- type TableName
- func (t *TableName) Database() string
- func (t *TableName) Format(buf *bytes.Buffer, f FmtFlags)
- func (t *TableName) NormalizeTableName() (*TableName, error)
- func (t *TableName) NormalizeTablePattern() (TablePattern, error)
- func (t *TableName) NormalizedTableName() TableName
- func (t *TableName) QualifyWithDatabase(database string) error
- func (t *TableName) String() string
- func (t *TableName) Table() string
- type TableNameReference
- type TableNameReferences
- type TableNameWithIndex
- type TableNameWithIndexList
- type TableNames
- type TablePattern
- type TablePatterns
- type TargetList
- type TimestampColType
- type TimestampTZColType
- type Truncate
- type Tuple
- func (t *Tuple) Eval(ctx *EvalContext) (Datum, error)
- func (node *Tuple) Format(buf *bytes.Buffer, f FmtFlags)
- func (node *Tuple) ResolvedType() Type
- func (node *Tuple) String() string
- func (expr *Tuple) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (expr *Tuple) Walk(v Visitor) Expr
- type Type
- type TypedExpr
- type TypedExprs
- type UnaryExpr
- func (expr *UnaryExpr) Eval(ctx *EvalContext) (Datum, error)
- func (node *UnaryExpr) Format(buf *bytes.Buffer, f FmtFlags)
- func (ta UnaryExpr) ResolvedType() Type
- func (node *UnaryExpr) String() string
- func (expr *UnaryExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
- func (node *UnaryExpr) TypedInnerExpr() TypedExpr
- func (expr *UnaryExpr) Walk(v Visitor) Expr
- type UnaryOp
- type UnaryOperator
- type UnionClause
- type UnionType
- type UniqueConstraint
- type UniqueConstraintTableDef
- type UnqualifiedStar
- func (expr UnqualifiedStar) Eval(ctx *EvalContext) (Datum, error)
- func (UnqualifiedStar) Format(buf *bytes.Buffer, _ FmtFlags)
- func (u UnqualifiedStar) NormalizeVarName() (VarName, error)
- func (UnqualifiedStar) ResolvedType() Type
- func (u UnqualifiedStar) String() string
- func (expr UnqualifiedStar) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
- func (UnqualifiedStar) Variable()
- func (expr UnqualifiedStar) Walk(_ Visitor) Expr
- type UnresolvedName
- func (expr UnresolvedName) Eval(ctx *EvalContext) (Datum, error)
- func (u UnresolvedName) Format(buf *bytes.Buffer, f FmtFlags)
- func (n UnresolvedName) NormalizeTableName() (*TableName, error)
- func (n UnresolvedName) NormalizeTablePattern() (TablePattern, error)
- func (n UnresolvedName) NormalizeUnqualifiedColumnItem() (*ColumnItem, error)
- func (n UnresolvedName) NormalizeVarName() (VarName, error)
- func (n UnresolvedName) ResolveFunction(searchPath []string) (*FunctionDefinition, error)
- func (UnresolvedName) ResolvedType() Type
- func (u UnresolvedName) String() string
- func (expr UnresolvedName) TypeCheck(s *SemaContext, desired Type) (TypedExpr, error)
- func (UnresolvedName) Variable()
- func (expr UnresolvedName) Walk(_ Visitor) Expr
- type UnresolvedNames
- type Update
- type UpdateExpr
- type UpdateExprs
- type UserPriority
- type UsingJoinCond
- type ValidationBehavior
- type ValuesClause
- type VarName
- type VariableExpr
- type VariadicType
- type Visitor
- type WalkableStmt
- type When
- type Where
- type Window
- type WindowDef
- type WindowFrame
- type WindowFunc
Constants ¶
const ( Distinct funcType All )
FuncExpr.Type
const ACTION = 57362
const ADD = 57363
const ALL = 57364
const ALTER = 57365
const ANALYSE = 57366
const ANALYZE = 57367
const AND = 57368
const ANNOTATE_TYPE = 57370
const ANY = 57369
const ARRAY = 57371
const AS = 57372
const ASC = 57373
const ASYMMETRIC = 57374
const AS_LA = 57628
const AT = 57375
const BCONST = 57348
const BEGIN = 57376
const BETWEEN = 57377
const BIGINT = 57378
const BIGSERIAL = 57379
const BIT = 57380
const BLOB = 57381
const BOOL = 57382
const BOOLEAN = 57383
const BOTH = 57384
const BY = 57385
const BYTEA = 57386
const BYTES = 57387
const CASCADE = 57388
const CASE = 57389
const CAST = 57390
const CHAR = 57391
const CHARACTER = 57392
const CHARACTERISTICS = 57393
const CHECK = 57394
const COALESCE = 57395
const COLLATE = 57396
const COLLATION = 57397
const COLUMN = 57398
const COLUMNS = 57399
const COMMIT = 57400
const COMMITTED = 57401
const CONCAT = 57402
const CONFLICT = 57403
const CONSTRAINT = 57404
const CONSTRAINTS = 57405
const COPY = 57406
const COVERING = 57407
const CREATE = 57408
const CROSS = 57409
const CUBE = 57410
const CURRENT = 57411
const CURRENT_CATALOG = 57412
const CURRENT_DATE = 57413
const CURRENT_ROLE = 57414
const CURRENT_TIME = 57415
const CURRENT_TIMESTAMP = 57416
const CURRENT_USER = 57417
const CYCLE = 57418
const DATA = 57419
const DATABASE = 57420
const DATABASES = 57421
const DATE = 57422
const DAY = 57423
const DEALLOCATE = 57427
const DEC = 57424
const DECIMAL = 57425
const DEFAULT = 57426
const DEFERRABLE = 57428
const DELETE = 57429
const DESC = 57430
const DISTINCT = 57431
const DO = 57432
const DOT_DOT = 57354
const DOUBLE = 57433
const DROP = 57434
const ELSE = 57435
const ENCODING = 57436
const END = 57437
const ERROR = 57361
const ESCAPE = 57438
const EXCEPT = 57439
const EXECUTE = 57441
const EXISTS = 57440
const EXPLAIN = 57442
const EXTRACT = 57443
const EXTRACT_DURATION = 57444
const FALSE = 57445
const FAMILY = 57446
const FCONST = 57350
const FETCH = 57447
const FILTER = 57448
const FIRST = 57449
const FLOAT = 57450
const FLOORDIV = 57451
const FOLLOWING = 57452
const FOR = 57453
const FORCE_INDEX = 57454
const FOREIGN = 57455
const FROM = 57456
const FULL = 57457
const GRANT = 57458
const GRANTS = 57459
const GREATER_EQUALS = 57356
const GREATEST = 57460
const GROUP = 57461
const GROUPING = 57462
const HAVING = 57463
const HELP = 57464
const HIGH = 57465
const HOUR = 57466
const ICONST = 57349
const IDENT = 57346
const IF = 57467
const IFNULL = 57468
const ILIKE = 57469
const IN = 57470
const INDEX = 57472
const INDEXES = 57473
const INITIALLY = 57474
const INNER = 57475
const INSERT = 57476
const INT = 57477
const INT64 = 57479
const INT8 = 57478
const INTEGER = 57480
const INTERLEAVE = 57471
const INTERSECT = 57481
const INTERVAL = 57482
const INTO = 57483
const IS = 57484
const ISOLATION = 57485
const InvalidColIdx = -1
InvalidColIdx is the index value of a non-initialized IndexedVar.
const JOIN = 57486
const KEY = 57487
const KEYS = 57488
const LATERAL = 57489
const LEADING = 57490
const LEAST = 57491
const LEFT = 57492
const LESS_EQUALS = 57355
const LEVEL = 57493
const LIKE = 57494
const LIMIT = 57495
const LOCAL = 57496
const LOCALTIME = 57497
const LOCALTIMESTAMP = 57498
const LOW = 57499
const LSHIFT = 57500
const MATCH = 57501
const MINUTE = 57502
const MONTH = 57503
const NAME = 57504
const NAMES = 57505
const NATURAL = 57506
const NEXT = 57507
const NO = 57508
const NORMAL = 57510
const NOT = 57511
const NOTHING = 57512
const NOT_EQUALS = 57357
const NOT_LA = 57626
const NOT_REGIMATCH = 57360
const NOT_REGMATCH = 57358
const NO_INDEX_JOIN = 57509
const NULL = 57513
const NULLIF = 57514
const NULLS = 57515
const NUMERIC = 57516
const OF = 57517
const OFF = 57518
const OFFSET = 57519
const ON = 57520
const ONLY = 57521
const OR = 57522
const ORDER = 57523
const ORDINALITY = 57524
const OUT = 57525
const OUTER = 57526
const OVER = 57527
const OVERLAPS = 57528
const OVERLAY = 57529
const PARENT = 57530
const PARTIAL = 57531
const PARTITION = 57532
const PASSWORD = 57533
const PLACEHOLDER = 57351
const PLACING = 57534
const POSITION = 57535
const POSTFIXOP = 57629
const PRECEDING = 57536
const PRECISION = 57537
const PREPARE = 57538
const PRIMARY = 57539
const PRIORITY = 57540
const RANGE = 57541
const READ = 57542
const REAL = 57543
const RECURSIVE = 57544
const REF = 57545
const REFERENCES = 57546
const REGIMATCH = 57359
const RELEASE = 57549
const RENAME = 57547
const REPEATABLE = 57548
const RESTRICT = 57550
const RETURNING = 57551
const REVOKE = 57552
const RIGHT = 57553
const ROLLBACK = 57554
const ROLLUP = 57555
const ROW = 57556
const ROWS = 57557
const RSHIFT = 57558
const RestartSavepointName string = "COCKROACH_RESTART"
RestartSavepointName is the only savepoint name that we accept, modulo capitalization.
const SAVEPOINT = 57559
const SCONST = 57347
const SEARCH = 57560
const SECOND = 57561
const SELECT = 57562
const SERIAL = 57563
const SERIALIZABLE = 57564
const SESSION = 57565
const SESSION_USER = 57566
const SET = 57567
const SHOW = 57568
const SIMILAR = 57569
const SIMPLE = 57570
const SMALLINT = 57571
const SMALLSERIAL = 57572
const SNAPSHOT = 57573
const SOME = 57574
const SPLIT = 57575
const SQL = 57576
const START = 57577
const STDIN = 57578
const STORING = 57581
const STRICT = 57579
const STRING = 57580
const SUBSTRING = 57582
const SYMMETRIC = 57583
const SYSTEM = 57584
const TABLE = 57585
const TABLES = 57586
const TEXT = 57587
const THEN = 57588
const TIME = 57589
const TIMESTAMP = 57590
const TIMESTAMPTZ = 57591
const TO = 57592
const TRAILING = 57593
const TRANSACTION = 57594
const TREAT = 57595
const TRIM = 57596
const TRUE = 57597
const TRUNCATE = 57598
const TYPE = 57599
const TYPEANNOTATE = 57353
const TYPECAST = 57352
const UMINUS = 57630
const UNBOUNDED = 57600
const UNCOMMITTED = 57601
const UNION = 57602
const UNIQUE = 57603
const UNKNOWN = 57604
const UPDATE = 57605
const UPSERT = 57606
const USER = 57607
const USERS = 57608
const USING = 57609
const VALID = 57610
const VALIDATE = 57611
const VALUE = 57612
const VALUES = 57613
const VARCHAR = 57614
const VARIADIC = 57615
const VARYING = 57617
const VIEW = 57616
const WHEN = 57618
const WHERE = 57619
const WINDOW = 57620
const WITH = 57621
const WITHIN = 57622
const WITHOUT = 57623
const WITH_LA = 57627
const YEAR = 57624
const ZONE = 57625
Variables ¶
var ( // DBoolTrue is a pointer to the DBool(true) value and can be used in // comparisons against Datum types. DBoolTrue = &constDBoolTrue // DBoolFalse is a pointer to the DBool(false) value and can be used in // comparisons against Datum types. DBoolFalse = &constDBoolFalse // DNull is the NULL Datum. DNull Datum = dNull{} )
var Aggregates = map[string][]Builtin{ "avg": { makeAggBuiltin(TypeInt, TypeDecimal, newIntAvgAggregate), makeAggBuiltin(TypeFloat, TypeFloat, newFloatAvgAggregate), makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalAvgAggregate), }, "bool_and": { makeAggBuiltin(TypeBool, TypeBool, newBoolAndAggregate), }, "bool_or": { makeAggBuiltin(TypeBool, TypeBool, newBoolOrAggregate), }, "concat_agg": { makeAggBuiltin(TypeString, TypeString, newStringConcatAggregate), makeAggBuiltin(TypeBytes, TypeBytes, newBytesConcatAggregate), }, "count": countImpls(), "max": makeAggBuiltins(newMaxAggregate, TypeBool, TypeInt, TypeFloat, TypeDecimal, TypeString, TypeBytes, TypeDate, TypeTimestamp, TypeTimestampTZ, TypeInterval), "min": makeAggBuiltins(newMinAggregate, TypeBool, TypeInt, TypeFloat, TypeDecimal, TypeString, TypeBytes, TypeDate, TypeTimestamp, TypeTimestampTZ, TypeInterval), "sum": { makeAggBuiltin(TypeInt, TypeDecimal, newIntSumAggregate), makeAggBuiltin(TypeFloat, TypeFloat, newFloatSumAggregate), makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalSumAggregate), }, "variance": { makeAggBuiltin(TypeInt, TypeDecimal, newIntVarianceAggregate), makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalVarianceAggregate), makeAggBuiltin(TypeFloat, TypeFloat, newFloatVarianceAggregate), }, "stddev": { makeAggBuiltin(TypeInt, TypeDecimal, newIntStdDevAggregate), makeAggBuiltin(TypeDecimal, TypeDecimal, newDecimalStdDevAggregate), makeAggBuiltin(TypeFloat, TypeFloat, newFloatStdDevAggregate), }, }
Aggregates are a special class of builtin functions that are wrapped at execution in a bucketing layer to combine (aggregate) the result of the function being run over many rows. See `aggregateFuncHolder` in the sql package. In particular they must not be simplified during normalization (and thus must be marked as impure), even when they are given a constant argument (e.g. SUM(1)). This is because aggregate functions must return NULL when they are no rows in the source table, so their evaluation must always be delayed until query execution. Exported for use in documentation.
var BinOps = map[BinaryOperator]binOpOverload{ Bitand: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, }, Bitor: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, }, Bitxor: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, }, Plus: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, BinOp{ LeftType: TypeFloat, RightType: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeInt, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDate, RightType: TypeInt, ReturnType: TypeDate, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeDate, ReturnType: TypeDate, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestamp, RightType: TypeInterval, ReturnType: TypeTimestamp, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInterval, RightType: TypeTimestamp, ReturnType: TypeTimestamp, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestampTZ, RightType: TypeInterval, ReturnType: TypeTimestampTZ, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInterval, RightType: TypeTimestampTZ, ReturnType: TypeTimestampTZ, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInterval, RightType: TypeInterval, ReturnType: TypeInterval, // contains filtered or unexported fields }, }, Minus: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, BinOp{ LeftType: TypeFloat, RightType: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeInt, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDate, RightType: TypeInt, ReturnType: TypeDate, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDate, RightType: TypeDate, ReturnType: TypeInt, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestamp, RightType: TypeTimestamp, ReturnType: TypeInterval, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestampTZ, ReturnType: TypeInterval, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestamp, RightType: TypeTimestampTZ, ReturnType: TypeInterval, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestamp, ReturnType: TypeInterval, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestamp, RightType: TypeInterval, ReturnType: TypeTimestamp, // contains filtered or unexported fields }, BinOp{ LeftType: TypeTimestampTZ, RightType: TypeInterval, ReturnType: TypeTimestampTZ, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInterval, RightType: TypeInterval, ReturnType: TypeInterval, // contains filtered or unexported fields }, }, Mult: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, BinOp{ LeftType: TypeFloat, RightType: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeInt, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeInterval, ReturnType: TypeInterval, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInterval, RightType: TypeInt, ReturnType: TypeInterval, // contains filtered or unexported fields }, }, Div: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeFloat, RightType: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeInt, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInterval, RightType: TypeInt, ReturnType: TypeInterval, // contains filtered or unexported fields }, }, FloorDiv: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, BinOp{ LeftType: TypeFloat, RightType: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeInt, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, }, Mod: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, BinOp{ LeftType: TypeFloat, RightType: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeDecimal, RightType: TypeInt, ReturnType: TypeDecimal, // contains filtered or unexported fields }, BinOp{ LeftType: TypeInt, RightType: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, }, Concat: { BinOp{ LeftType: TypeString, RightType: TypeString, ReturnType: TypeString, // contains filtered or unexported fields }, BinOp{ LeftType: TypeBytes, RightType: TypeBytes, ReturnType: TypeBytes, // contains filtered or unexported fields }, }, LShift: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, }, RShift: { BinOp{ LeftType: TypeInt, RightType: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, }, }
BinOps contains the binary operations indexed by operation type.
var Builtins = map[string][]Builtin{ "length": { stringBuiltin1(func(s string) (Datum, error) { return NewDInt(DInt(utf8.RuneCountInString(s))), nil }, TypeInt), bytesBuiltin1(func(s string) (Datum, error) { return NewDInt(DInt(len(s))), nil }, TypeInt), }, "octet_length": { stringBuiltin1(func(s string) (Datum, error) { return NewDInt(DInt(len(s))), nil }, TypeInt), bytesBuiltin1(func(s string) (Datum, error) { return NewDInt(DInt(len(s))), nil }, TypeInt), }, "lower": {stringBuiltin1(func(s string) (Datum, error) { return NewDString(strings.ToLower(s)), nil }, TypeString)}, "upper": {stringBuiltin1(func(s string) (Datum, error) { return NewDString(strings.ToUpper(s)), nil }, TypeString)}, "substr": substringImpls, "substring": substringImpls, "concat": { Builtin{ Types: VariadicType{TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "concat_ws": { Builtin{ Types: VariadicType{TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "to_uuid": { Builtin{ Types: ArgTypes{TypeString}, ReturnType: TypeBytes, // contains filtered or unexported fields }, }, "from_uuid": { Builtin{ Types: ArgTypes{TypeBytes}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "from_ip": { Builtin{ Types: ArgTypes{TypeBytes}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "to_ip": { Builtin{ Types: ArgTypes{TypeString}, ReturnType: TypeBytes, // contains filtered or unexported fields }, }, "split_part": { Builtin{ Types: ArgTypes{TypeString, TypeString, TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "repeat": { Builtin{ Types: ArgTypes{TypeString, TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "ascii": {stringBuiltin1(func(s string) (Datum, error) { for _, ch := range s { return NewDInt(DInt(ch)), nil } return nil, errEmptyInputString }, TypeInt)}, "md5": {stringBuiltin1(func(s string) (Datum, error) { return NewDString(fmt.Sprintf("%x", md5.Sum([]byte(s)))), nil }, TypeString)}, "sha1": {stringBuiltin1(func(s string) (Datum, error) { return NewDString(fmt.Sprintf("%x", sha1.Sum([]byte(s)))), nil }, TypeString)}, "sha256": {stringBuiltin1(func(s string) (Datum, error) { return NewDString(fmt.Sprintf("%x", sha256.Sum256([]byte(s)))), nil }, TypeString)}, "to_hex": { Builtin{ Types: ArgTypes{TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "strpos": {stringBuiltin2(func(s, substring string) (Datum, error) { index := strings.Index(s, substring) if index < 0 { return NewDInt(0), nil } return NewDInt(DInt(utf8.RuneCountInString(s[:index]) + 1)), nil }, TypeInt)}, "overlay": { Builtin{ Types: ArgTypes{TypeString, TypeString, TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeString, TypeString, TypeInt, TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "btrim": { stringBuiltin2(func(s, chars string) (Datum, error) { return NewDString(strings.Trim(s, chars)), nil }, TypeString), stringBuiltin1(func(s string) (Datum, error) { return NewDString(strings.TrimSpace(s)), nil }, TypeString), }, "ltrim": { stringBuiltin2(func(s, chars string) (Datum, error) { return NewDString(strings.TrimLeft(s, chars)), nil }, TypeString), stringBuiltin1(func(s string) (Datum, error) { return NewDString(strings.TrimLeftFunc(s, unicode.IsSpace)), nil }, TypeString), }, "rtrim": { stringBuiltin2(func(s, chars string) (Datum, error) { return NewDString(strings.TrimRight(s, chars)), nil }, TypeString), stringBuiltin1(func(s string) (Datum, error) { return NewDString(strings.TrimRightFunc(s, unicode.IsSpace)), nil }, TypeString), }, "reverse": {stringBuiltin1(func(s string) (Datum, error) { runes := []rune(s) for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 { runes[i], runes[j] = runes[j], runes[i] } return NewDString(string(runes)), nil }, TypeString)}, "replace": {stringBuiltin3( "input", "from", "to", func(input, from, to string) (Datum, error) { return NewDString(strings.Replace(input, from, to, -1)), nil }, TypeString, "Replace all occurrences of 'from' with 'to' in 'input'", )}, "translate": {stringBuiltin3( "input", "from", "to", func(s, from, to string) (Datum, error) { const deletionRune = utf8.MaxRune + 1 translation := make(map[rune]rune, len(from)) for _, fromRune := range from { toRune, size := utf8.DecodeRuneInString(to) if toRune == utf8.RuneError { toRune = deletionRune } else { to = to[size:] } translation[fromRune] = toRune } runes := make([]rune, 0, len(s)) for _, c := range s { if t, ok := translation[c]; ok { if t != deletionRune { runes = append(runes, t) } } else { runes = append(runes, c) } } return NewDString(string(runes)), nil }, TypeString, "")}, "regexp_extract": { Builtin{ Types: ArgTypes{TypeString, TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "regexp_replace": { Builtin{ Types: ArgTypes{TypeString, TypeString, TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeString, TypeString, TypeString, TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "initcap": {stringBuiltin1(func(s string) (Datum, error) { return NewDString(strings.Title(strings.ToLower(s))), nil }, TypeString)}, "left": { Builtin{ Types: ArgTypes{TypeBytes, TypeInt}, ReturnType: TypeBytes, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeString, TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "right": { Builtin{ Types: ArgTypes{TypeBytes, TypeInt}, ReturnType: TypeBytes, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeString, TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "random": { Builtin{ Types: ArgTypes{}, ReturnType: TypeFloat, // contains filtered or unexported fields }, }, "experimental_unique_bytes": { Builtin{ Types: ArgTypes{}, ReturnType: TypeBytes, // contains filtered or unexported fields }, }, "unique_rowid": { Builtin{ Types: ArgTypes{}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "experimental_uuid_v4": {uuidV4Impl}, "uuid_v4": {uuidV4Impl}, "greatest": { Builtin{ Types: AnyType{}, ReturnType: TypeAny, // contains filtered or unexported fields }, }, "least": { Builtin{ Types: AnyType{}, ReturnType: TypeAny, // contains filtered or unexported fields }, }, "experimental_strftime": { Builtin{ Types: ArgTypes{TypeTimestamp, TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeDate, TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeTimestampTZ, TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "experimental_strptime": { Builtin{ Types: ArgTypes{TypeString, TypeString}, ReturnType: TypeTimestampTZ, // contains filtered or unexported fields }, }, "age": { Builtin{ Types: ArgTypes{TypeTimestampTZ}, ReturnType: TypeInterval, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeTimestampTZ, TypeTimestampTZ}, ReturnType: TypeInterval, // contains filtered or unexported fields }, }, "current_date": { Builtin{ Types: ArgTypes{}, ReturnType: TypeDate, // contains filtered or unexported fields }, }, "now": txnTSImpl, "current_timestamp": txnTSImpl, "transaction_timestamp": txnTSImpl, "statement_timestamp": { Builtin{ Types: ArgTypes{}, ReturnType: TypeTimestampTZ, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{}, ReturnType: TypeTimestamp, // contains filtered or unexported fields }, }, "cluster_logical_timestamp": { Builtin{ Types: ArgTypes{}, ReturnType: TypeDecimal, // contains filtered or unexported fields }, }, "clock_timestamp": { Builtin{ Types: ArgTypes{}, ReturnType: TypeTimestampTZ, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{}, ReturnType: TypeTimestamp, // contains filtered or unexported fields }, }, "extract": { Builtin{ Types: ArgTypes{TypeString, TypeTimestamp}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "extract_duration": { Builtin{ Types: ArgTypes{TypeString, TypeInterval}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "abs": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Abs(x))), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { dd := &DDecimal{} dd.Abs(x) return dd, nil }), Builtin{ Types: ArgTypes{TypeInt}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "acos": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Acos(x))), nil }), }, "asin": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Asin(x))), nil }), }, "atan": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Atan(x))), nil }), }, "atan2": { floatBuiltin2(func(x, y float64) (Datum, error) { return NewDFloat(DFloat(math.Atan2(x, y))), nil }), }, "cbrt": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Cbrt(x))), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { dd := &DDecimal{} decimal.Cbrt(&dd.Dec, x, decimal.Precision) return dd, nil }), }, "ceil": ceilImpl, "ceiling": ceilImpl, "cos": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Cos(x))), nil }), }, "cot": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(1 / math.Tan(x))), nil }), }, "degrees": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(180.0 * x / math.Pi)), nil }), }, "div": { floatBuiltin2(func(x, y float64) (Datum, error) { return NewDFloat(DFloat(math.Trunc(x / y))), nil }), decimalBuiltin2(func(x, y *inf.Dec) (Datum, error) { if y.Sign() == 0 { return nil, errDivByZero } dd := &DDecimal{} dd.QuoRound(x, y, 0, inf.RoundDown) return dd, nil }), { Types: ArgTypes{TypeInt, TypeInt}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "exp": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Exp(x))), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { return expDecimal(x) }), }, "floor": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Floor(x))), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { dd := &DDecimal{} dd.Round(x, 0, inf.RoundFloor) return dd, nil }), }, "ln": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Log(x))), nil }), decimalLogFn(decimal.Log), }, "log": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Log10(x))), nil }), decimalLogFn(decimal.Log10), }, "mod": { floatBuiltin2(func(x, y float64) (Datum, error) { return NewDFloat(DFloat(math.Mod(x, y))), nil }), decimalBuiltin2(func(x, y *inf.Dec) (Datum, error) { if y.Sign() == 0 { return nil, errZeroModulus } dd := &DDecimal{} decimal.Mod(&dd.Dec, x, y) return dd, nil }), Builtin{ Types: ArgTypes{TypeInt, TypeInt}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "pi": { Builtin{ Types: ArgTypes{}, ReturnType: TypeFloat, // contains filtered or unexported fields }, }, "pow": powImpls, "power": powImpls, "radians": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(x * math.Pi / 180.0)), nil }), }, "round": { floatBuiltin1(func(x float64) (Datum, error) { return round(x, 0) }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { return roundDecimal(x, 0) }), Builtin{ Types: ArgTypes{TypeFloat, TypeInt}, ReturnType: TypeFloat, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeDecimal, TypeInt}, ReturnType: TypeDecimal, // contains filtered or unexported fields }, }, "sin": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Sin(x))), nil }), }, "sign": { floatBuiltin1(func(x float64) (Datum, error) { switch { case x < 0: return NewDFloat(-1), nil case x == 0: return NewDFloat(0), nil } return NewDFloat(1), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { return NewDFloat(DFloat(x.Sign())), nil }), Builtin{ Types: ArgTypes{TypeInt}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "sqrt": { floatBuiltin1(func(x float64) (Datum, error) { if x < 0 { return nil, errSqrtOfNegNumber } return NewDFloat(DFloat(math.Sqrt(x))), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { if x.Sign() < 0 { return nil, errSqrtOfNegNumber } dd := &DDecimal{} decimal.Sqrt(&dd.Dec, x, decimal.Precision) return dd, nil }), }, "tan": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Tan(x))), nil }), }, "trunc": { floatBuiltin1(func(x float64) (Datum, error) { return NewDFloat(DFloat(math.Trunc(x))), nil }), decimalBuiltin1(func(x *inf.Dec) (Datum, error) { dd := &DDecimal{} dd.Round(x, 0, inf.RoundDown) return dd, nil }), }, "array_length": { Builtin{ Types: ArgTypes{TypeArray, TypeInt}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "array_lower": { Builtin{ Types: ArgTypes{TypeArray, TypeInt}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "array_upper": { Builtin{ Types: ArgTypes{TypeArray, TypeInt}, ReturnType: TypeInt, // contains filtered or unexported fields }, }, "version": { Builtin{ Types: ArgTypes{}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "current_schema": { Builtin{ Types: ArgTypes{}, ReturnType: TypeString, // contains filtered or unexported fields }, }, "current_schemas": { Builtin{ Types: ArgTypes{TypeBool}, ReturnType: TypeArray, // contains filtered or unexported fields }, }, "pg_catalog.pg_typeof": { Builtin{ Types: ArgTypes{TypeInt}, ReturnType: TypeString, // contains filtered or unexported fields }, Builtin{ Types: ArgTypes{TypeString}, ReturnType: TypeString, // contains filtered or unexported fields }, }, }
Builtins contains the built-in functions indexed by name.
var CmpOps = map[ComparisonOperator]cmpOpOverload{ EQ: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeCollatedString, RightType: TypeCollatedString, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeBytes, RightType: TypeBytes, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeBool, RightType: TypeBool, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDate, RightType: TypeDate, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestamp, RightType: TypeTimestamp, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestampTZ, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestamp, RightType: TypeTimestampTZ, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestamp, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInterval, RightType: TypeInterval, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTuple, RightType: TypeTuple, // contains filtered or unexported fields }, }, LT: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeCollatedString, RightType: TypeCollatedString, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeBytes, RightType: TypeBytes, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeBool, RightType: TypeBool, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDate, RightType: TypeDate, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestamp, RightType: TypeTimestamp, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestampTZ, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestamp, RightType: TypeTimestampTZ, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestamp, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInterval, RightType: TypeInterval, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTuple, RightType: TypeTuple, // contains filtered or unexported fields }, }, LE: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeCollatedString, RightType: TypeCollatedString, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeBytes, RightType: TypeBytes, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeBool, RightType: TypeBool, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeInt, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInt, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDecimal, RightType: TypeFloat, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeFloat, RightType: TypeDecimal, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeDate, RightType: TypeDate, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestamp, RightType: TypeTimestamp, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestampTZ, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestampTZ, RightType: TypeTimestamp, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTimestamp, RightType: TypeTimestampTZ, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeInterval, RightType: TypeInterval, // contains filtered or unexported fields }, CmpOp{ LeftType: TypeTuple, RightType: TypeTuple, // contains filtered or unexported fields }, }, In: { makeEvalTupleIn(TypeBool), makeEvalTupleIn(TypeInt), makeEvalTupleIn(TypeFloat), makeEvalTupleIn(TypeDecimal), makeEvalTupleIn(TypeString), makeEvalTupleIn(TypeCollatedString), makeEvalTupleIn(TypeBytes), makeEvalTupleIn(TypeDate), makeEvalTupleIn(TypeTimestamp), makeEvalTupleIn(TypeTimestampTZ), makeEvalTupleIn(TypeInterval), makeEvalTupleIn(TypeTuple), }, Like: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, }, ILike: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, }, SimilarTo: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, }, RegMatch: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, }, RegIMatch: { CmpOp{ LeftType: TypeString, RightType: TypeString, // contains filtered or unexported fields }, }, }
CmpOps contains the comparison operations indexed by operation type.
var NoTypePreference = Type(nil)
NoTypePreference can be provided to TypeCheck's desired type parameter to indicate that the caller of the function has no preference on the type of the resulting TypedExpr.
var StarDatumInstance = &StarDatum{}
StarDatumInstance can be used as common instance for all uses of StarDatum.
var UnaryOps = map[UnaryOperator]unaryOpOverload{ UnaryPlus: { UnaryOp{ Typ: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, UnaryOp{ Typ: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, UnaryOp{ Typ: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, }, UnaryMinus: { UnaryOp{ Typ: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, UnaryOp{ Typ: TypeFloat, ReturnType: TypeFloat, // contains filtered or unexported fields }, UnaryOp{ Typ: TypeDecimal, ReturnType: TypeDecimal, // contains filtered or unexported fields }, }, UnaryComplement: { UnaryOp{ Typ: TypeInt, ReturnType: TypeInt, // contains filtered or unexported fields }, }, }
UnaryOps contains the unary operations indexed by operation type.
Functions ¶
func AsStringWithFlags ¶
func AsStringWithFlags(n NodeFormatter, f FmtFlags) string
AsStringWithFlags pretty prints a node to a string given specific flags.
func ContainsVars ¶
ContainsVars returns true if the expression contains any variables.
func FindEqualComparisonFunction ¶
func FindEqualComparisonFunction( leftType, rightType Type, ) (func(*EvalContext, Datum, Datum) (DBool, error), bool)
FindEqualComparisonFunction looks up an overload of the "=" operator for a given pair of input operand types.
func FormatNode ¶
func FormatNode(buf *bytes.Buffer, f FmtFlags, n NodeFormatter)
FormatNode recurses into a node for pretty-printing. Flag-driven special cases can hook into this.
func IsNumericOne ¶
IsNumericOne returns true if the datum is a number and equal to one.
func IsNumericZero ¶
IsNumericZero returns true if the datum is a number and equal to zero.
func ReNormalizeName ¶
ReNormalizeName performs the same work as NormalizeName but when the string originates from the database. We define a different function so as to be able to track usage of this function (cf. #8200).
func SimilarEscape ¶
SimilarEscape converts a SQL:2008 regexp pattern to POSIX style, so it can be used by our regexp engine.
func ValidateRestartCheckpoint ¶
ValidateRestartCheckpoint checks that a checkpoint name is our magic restart value. We accept everything with the desired prefix because at least the C++ libpqxx appends sequence numbers to the savepoint name specified by the user.
func WalkExprConst ¶
WalkExprConst is a variant of WalkExpr for visitors that do not modify the expression.
Types ¶
type AggregateFunc ¶
type AggregateFunc interface { // Add accumulates the passed datum into the AggregateFunc. Add(Datum) // Result returns the current value of the accumulation. This value // will be a deep copy of any AggregateFunc internal state, so that // it will not be mutated by additional calls to Add. Result() Datum }
AggregateFunc accumulates the result of a function of a Datum.
func NewIdentAggregate ¶
func NewIdentAggregate() AggregateFunc
NewIdentAggregate returns an identAggregate (see comment on struct).
type AliasClause ¶
AliasClause represents an alias, optionally with a column list: "AS name" or "AS name(col1, col2)".
type AliasedTableExpr ¶
type AliasedTableExpr struct { Expr TableExpr Hints *IndexHints As AliasClause }
AliasedTableExpr represents a table expression coupled with an optional alias.
func (*AliasedTableExpr) Format ¶
func (node *AliasedTableExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AliasedTableExpr) String ¶
func (node *AliasedTableExpr) String() string
type AllColumnsSelector ¶
type AllColumnsSelector struct {
TableName
}
AllColumnsSelector corresponds to a selection of all columns in a table when used in a SELECT clause. (e.g. `table.*`)
func (*AllColumnsSelector) Eval ¶
func (expr *AllColumnsSelector) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*AllColumnsSelector) Format ¶
func (a *AllColumnsSelector) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AllColumnsSelector) NormalizeVarName ¶
func (a *AllColumnsSelector) NormalizeVarName() (VarName, error)
NormalizeVarName is a no-op for AllColumnsSelector (already normalized)
func (*AllColumnsSelector) ResolvedType ¶
func (*AllColumnsSelector) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (*AllColumnsSelector) String ¶
func (a *AllColumnsSelector) String() string
func (*AllColumnsSelector) TypeCheck ¶
func (expr *AllColumnsSelector) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*AllColumnsSelector) Variable ¶
func (a *AllColumnsSelector) Variable()
Variable implements the VariableExpr interface. Although, the AllColumnsSelector ought to be replaced to an IndexedVar before the points the VariableExpr interface is used.
func (*AllColumnsSelector) Walk ¶
func (expr *AllColumnsSelector) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type AllTablesSelector ¶
type AllTablesSelector struct {
Database Name
}
AllTablesSelector corresponds to a selection of all tables in a database, e.g. when used with GRANT.
func (*AllTablesSelector) Format ¶
func (at *AllTablesSelector) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AllTablesSelector) NormalizeTablePattern ¶
func (at *AllTablesSelector) NormalizeTablePattern() (TablePattern, error)
NormalizeTablePattern implements the TablePattern interface.
func (*AllTablesSelector) QualifyWithDatabase ¶
func (at *AllTablesSelector) QualifyWithDatabase(database string) error
QualifyWithDatabase adds an indirection for the database, if it's missing. It transforms: * -> database.*
func (*AllTablesSelector) String ¶
func (at *AllTablesSelector) String() string
type AlterTable ¶
type AlterTable struct { IfExists bool Table NormalizableTableName Cmds AlterTableCmds }
AlterTable represents an ALTER TABLE statement.
func (*AlterTable) Format ¶
func (node *AlterTable) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AlterTable) StatementTag ¶
func (*AlterTable) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*AlterTable) StatementType ¶
func (*AlterTable) StatementType() StatementType
StatementType implements the Statement interface.
func (*AlterTable) String ¶
func (n *AlterTable) String() string
type AlterTableAddColumn ¶
type AlterTableAddColumn struct { IfNotExists bool ColumnDef *ColumnTableDef // contains filtered or unexported fields }
AlterTableAddColumn represents an ADD COLUMN command.
func (*AlterTableAddColumn) Format ¶
func (node *AlterTableAddColumn) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AlterTableAddColumn) String ¶
func (n *AlterTableAddColumn) String() string
type AlterTableAddConstraint ¶
type AlterTableAddConstraint struct { ConstraintDef ConstraintTableDef ValidationBehavior ValidationBehavior }
AlterTableAddConstraint represents an ADD CONSTRAINT command.
func (*AlterTableAddConstraint) Format ¶
func (node *AlterTableAddConstraint) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AlterTableAddConstraint) String ¶
func (n *AlterTableAddConstraint) String() string
type AlterTableCmd ¶
type AlterTableCmd interface { NodeFormatter // contains filtered or unexported methods }
AlterTableCmd represents a table modification operation.
type AlterTableCmds ¶
type AlterTableCmds []AlterTableCmd
AlterTableCmds represents a list of table alterations.
func (AlterTableCmds) Format ¶
func (node AlterTableCmds) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (AlterTableCmds) String ¶
func (n AlterTableCmds) String() string
type AlterTableDropColumn ¶
type AlterTableDropColumn struct { IfExists bool Column Name DropBehavior DropBehavior // contains filtered or unexported fields }
AlterTableDropColumn represents a DROP COLUMN command.
func (*AlterTableDropColumn) Format ¶
func (node *AlterTableDropColumn) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AlterTableDropColumn) String ¶
func (n *AlterTableDropColumn) String() string
type AlterTableDropConstraint ¶
type AlterTableDropConstraint struct { IfExists bool Constraint Name DropBehavior DropBehavior }
AlterTableDropConstraint represents a DROP CONSTRAINT command.
func (*AlterTableDropConstraint) Format ¶
func (node *AlterTableDropConstraint) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AlterTableDropConstraint) String ¶
func (n *AlterTableDropConstraint) String() string
type AlterTableDropNotNull ¶
type AlterTableDropNotNull struct { Column Name // contains filtered or unexported fields }
AlterTableDropNotNull represents an ALTER COLUMN DROP NOT NULL command.
func (*AlterTableDropNotNull) Format ¶
func (node *AlterTableDropNotNull) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AlterTableDropNotNull) GetColumn ¶
func (node *AlterTableDropNotNull) GetColumn() Name
GetColumn implements the ColumnMutationCmd interface.
func (*AlterTableDropNotNull) String ¶
func (n *AlterTableDropNotNull) String() string
type AlterTableSetDefault ¶
type AlterTableSetDefault struct { Column Name Default Expr // contains filtered or unexported fields }
AlterTableSetDefault represents an ALTER COLUMN SET DEFAULT or DROP DEFAULT command.
func (*AlterTableSetDefault) Format ¶
func (node *AlterTableSetDefault) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*AlterTableSetDefault) GetColumn ¶
func (node *AlterTableSetDefault) GetColumn() Name
GetColumn implements the ColumnMutationCmd interface.
func (*AlterTableSetDefault) String ¶
func (n *AlterTableSetDefault) String() string
type AlterTableValidateConstraint ¶
type AlterTableValidateConstraint struct {
Constraint Name
}
AlterTableValidateConstraint represents a VALIDATE CONSTRAINT command.
type AndExpr ¶
type AndExpr struct {
Left, Right Expr
// contains filtered or unexported fields
}
AndExpr represents an AND expression.
func NewTypedAndExpr ¶
NewTypedAndExpr returns a new AndExpr that is verified to be well-typed.
func (*AndExpr) Eval ¶
func (expr *AndExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (AndExpr) ResolvedType ¶
func (ta AndExpr) ResolvedType() Type
func (*AndExpr) TypeCheck ¶
func (expr *AndExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*AndExpr) TypedRight ¶
TypedRight returns the AndExpr's right expression as a TypedExpr.
type AnnotateTypeExpr ¶
type AnnotateTypeExpr struct { Expr Expr Type ColumnType // contains filtered or unexported fields }
AnnotateTypeExpr represents a ANNOTATE_TYPE(expr, type) expression.
func (*AnnotateTypeExpr) Eval ¶
func (expr *AnnotateTypeExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*AnnotateTypeExpr) Format ¶
func (node *AnnotateTypeExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (AnnotateTypeExpr) ResolvedType ¶
func (ta AnnotateTypeExpr) ResolvedType() Type
func (*AnnotateTypeExpr) String ¶
func (node *AnnotateTypeExpr) String() string
func (*AnnotateTypeExpr) TypeCheck ¶
func (expr *AnnotateTypeExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*AnnotateTypeExpr) TypedInnerExpr ¶
func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr
TypedInnerExpr returns the AnnotateTypeExpr's inner expression as a TypedExpr.
func (*AnnotateTypeExpr) Walk ¶
func (expr *AnnotateTypeExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type AnyType ¶
type AnyType struct{}
AnyType is a typeList implementation that accepts any arguments.
type ArgTypes ¶
type ArgTypes []Type
ArgTypes is a typeList implementation that accepts a specific number of argument types.
type Array ¶
type Array struct { Exprs Exprs // contains filtered or unexported fields }
Array represents an array constructor.
func (*Array) Eval ¶
func (t *Array) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (Array) ResolvedType ¶
func (ta Array) ResolvedType() Type
type ArraySubscript ¶
ArraySubscript corresponds to the syntax `<name>[ ... ]`.
type BeginTransaction ¶
type BeginTransaction struct { Isolation IsolationLevel UserPriority UserPriority }
BeginTransaction represents a BEGIN statement
func (*BeginTransaction) Format ¶
func (node *BeginTransaction) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*BeginTransaction) StatementTag ¶
func (*BeginTransaction) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*BeginTransaction) StatementType ¶
func (*BeginTransaction) StatementType() StatementType
StatementType implements the Statement interface.
func (*BeginTransaction) String ¶
func (n *BeginTransaction) String() string
type BinOp ¶
type BinOp struct { LeftType Type RightType Type ReturnType Type // contains filtered or unexported fields }
BinOp is a binary operator.
type BinaryExpr ¶
type BinaryExpr struct { Operator BinaryOperator Left, Right Expr // contains filtered or unexported fields }
BinaryExpr represents a binary value expression.
func (*BinaryExpr) Eval ¶
func (expr *BinaryExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*BinaryExpr) Format ¶
func (node *BinaryExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (BinaryExpr) ResolvedType ¶
func (ta BinaryExpr) ResolvedType() Type
func (*BinaryExpr) String ¶
func (node *BinaryExpr) String() string
func (*BinaryExpr) TypeCheck ¶
func (expr *BinaryExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*BinaryExpr) TypedLeft ¶
func (node *BinaryExpr) TypedLeft() TypedExpr
TypedLeft returns the BinaryExpr's left expression as a TypedExpr.
func (*BinaryExpr) TypedRight ¶
func (node *BinaryExpr) TypedRight() TypedExpr
TypedRight returns the BinaryExpr's right expression as a TypedExpr.
func (*BinaryExpr) Walk ¶
func (expr *BinaryExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type BinaryOperator ¶
type BinaryOperator int
BinaryOperator represents a binary operator.
const ( Bitand BinaryOperator = iota Bitor Bitxor Plus Minus Mult Div FloorDiv Mod Concat LShift RShift )
BinaryExpr.Operator
func (BinaryOperator) String ¶
func (i BinaryOperator) String() string
type BoolColType ¶
type BoolColType struct {
Name string
}
BoolColType represents a BOOLEAN type.
func (*BoolColType) Format ¶
func (node *BoolColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*BoolColType) String ¶
func (node *BoolColType) String() string
type Builtin ¶
type Builtin struct { Types typeList ReturnType Type Info string AggregateFunc func() AggregateFunc WindowFunc func() WindowFunc // contains filtered or unexported fields }
Builtin is a built-in function.
func (Builtin) Class ¶
func (b Builtin) Class() FunctionClass
Class returns the FunctionClass of this builtin.
type BytesColType ¶
type BytesColType struct {
Name string
}
BytesColType represents a BYTES or BLOB type.
func (*BytesColType) Format ¶
func (node *BytesColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*BytesColType) String ¶
func (node *BytesColType) String() string
type CaseExpr ¶
type CaseExpr struct { Expr Expr Whens []*When Else Expr // contains filtered or unexported fields }
CaseExpr represents a CASE expression.
func (*CaseExpr) CopyNode ¶
CopyNode makes a copy of this Expr without recursing in any child Exprs.
func (*CaseExpr) Eval ¶
func (expr *CaseExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (CaseExpr) ResolvedType ¶
func (ta CaseExpr) ResolvedType() Type
type CastExpr ¶
type CastExpr struct { Expr Expr Type ColumnType // contains filtered or unexported fields }
CastExpr represents a CAST(expr AS type) expression.
func (*CastExpr) Eval ¶
func (expr *CastExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (CastExpr) ResolvedType ¶
func (ta CastExpr) ResolvedType() Type
type CheckConstraintTableDef ¶
CheckConstraintTableDef represents a check constraint within a CREATE TABLE statement.
type CoalesceExpr ¶
CoalesceExpr represents a COALESCE or IFNULL expression.
func (*CoalesceExpr) CopyNode ¶
func (expr *CoalesceExpr) CopyNode() *CoalesceExpr
CopyNode makes a copy of this Expr without recursing in any child Exprs.
func (*CoalesceExpr) Eval ¶
func (expr *CoalesceExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*CoalesceExpr) Format ¶
func (node *CoalesceExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (CoalesceExpr) ResolvedType ¶
func (ta CoalesceExpr) ResolvedType() Type
func (*CoalesceExpr) String ¶
func (node *CoalesceExpr) String() string
func (*CoalesceExpr) TypeCheck ¶
func (expr *CoalesceExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*CoalesceExpr) TypedExprAt ¶
func (node *CoalesceExpr) TypedExprAt(idx int) TypedExpr
TypedExprAt returns the expression at the specified index as a TypedExpr.
func (*CoalesceExpr) Walk ¶
func (expr *CoalesceExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type CollateExpr ¶
CollateExpr represents an (expr COLLATE locale) expression.
func (*CollateExpr) Eval ¶
func (expr *CollateExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*CollateExpr) Format ¶
func (node *CollateExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (CollateExpr) ResolvedType ¶
func (ta CollateExpr) ResolvedType() Type
func (*CollateExpr) String ¶
func (node *CollateExpr) String() string
func (*CollateExpr) TypeCheck ¶
func (expr *CollateExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*CollateExpr) Walk ¶
func (expr *CollateExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type CollationEnvironment ¶
type CollationEnvironment struct {
// contains filtered or unexported fields
}
CollationEnvironment stores the state needed by NewDCollatedString to construct collation keys efficiently.
type ColumnCheckConstraint ¶
type ColumnCheckConstraint struct {
Expr Expr
}
ColumnCheckConstraint represents either a check on a column.
type ColumnDefault ¶
type ColumnDefault struct {
Expr Expr
}
ColumnDefault represents a DEFAULT clause for a column.
type ColumnFKConstraint ¶
type ColumnFKConstraint struct { Table NormalizableTableName Col Name // empty-string means use PK }
ColumnFKConstraint represents a FK-constaint on a column.
type ColumnFamilyConstraint ¶
ColumnFamilyConstraint represents FAMILY on a column.
type ColumnItem ¶
type ColumnItem struct { // TableName holds the table prefix, if the name refers to a column. TableName TableName // ColumnName names the designated column. ColumnName Name // Selector defines which sub-part of the variable is being // accessed. Selector NameParts }
ColumnItem corresponds to the name of a column or sub-item of a column in an expression.
func (*ColumnItem) Column ¶
func (c *ColumnItem) Column() string
Column retrieves the unqualified column name.
func (*ColumnItem) Eval ¶
func (expr *ColumnItem) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*ColumnItem) Format ¶
func (c *ColumnItem) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ColumnItem) NormalizeVarName ¶
func (c *ColumnItem) NormalizeVarName() (VarName, error)
NormalizeVarName is a no-op for ColumnItem (already normalized)
func (*ColumnItem) ResolvedType ¶
func (c *ColumnItem) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (*ColumnItem) String ¶
func (c *ColumnItem) String() string
func (*ColumnItem) TypeCheck ¶
func (expr *ColumnItem) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface. This function has a valid implementation only for testing within this package. During query execution, ColumnItems are replaced to IndexedVars prior to type checking.
func (*ColumnItem) Variable ¶
func (c *ColumnItem) Variable()
Variable implements the VariableExpr interface. Although, the ColumnItem ought to be replaced to an IndexedVar before the points the VariableExpr interface is used.
func (*ColumnItem) Walk ¶
func (expr *ColumnItem) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type ColumnMutationCmd ¶
type ColumnMutationCmd interface { AlterTableCmd GetColumn() Name }
ColumnMutationCmd is the subset of AlterTableCmds that modify an existing column.
type ColumnQualification ¶
type ColumnQualification interface {
// contains filtered or unexported methods
}
ColumnQualification represents a constraint on a column.
type ColumnTableDef ¶
type ColumnTableDef struct { Name Name Type ColumnType Nullable struct { Nullability Nullability ConstraintName Name } PrimaryKey bool Unique bool UniqueConstraintName Name DefaultExpr struct { Expr Expr ConstraintName Name } CheckExprs []ColumnTableDefCheckExpr References struct { Table NormalizableTableName Col Name ConstraintName Name } Family struct { Name Name Create bool IfNotExists bool } }
ColumnTableDef represents a column definition within a CREATE TABLE statement.
func (*ColumnTableDef) Format ¶
func (node *ColumnTableDef) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ColumnTableDef) HasColumnFamily ¶
func (node *ColumnTableDef) HasColumnFamily() bool
HasColumnFamily returns if the ColumnTableDef has a column family.
func (*ColumnTableDef) HasDefaultExpr ¶
func (node *ColumnTableDef) HasDefaultExpr() bool
HasDefaultExpr returns if the ColumnTableDef has a default expression.
func (*ColumnTableDef) HasFKConstraint ¶
func (node *ColumnTableDef) HasFKConstraint() bool
HasFKConstraint returns if the ColumnTableDef has a foreign key constraint.
type ColumnTableDefCheckExpr ¶
ColumnTableDefCheckExpr represents a check constraint on a column definition within a CREATE TABLE statement.
type ColumnType ¶
type ColumnType interface { fmt.Stringer NodeFormatter // contains filtered or unexported methods }
ColumnType represents a type in a column definition.
func DatumTypeToColumnType ¶
func DatumTypeToColumnType(t Type) (ColumnType, error)
DatumTypeToColumnType produces a SQL column type equivalent to the given Datum type. Used to generate CastExpr nodes during normalization.
type CommitTransaction ¶
type CommitTransaction struct{}
CommitTransaction represents a COMMIT statement.
func (*CommitTransaction) Format ¶
func (node *CommitTransaction) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*CommitTransaction) StatementTag ¶
func (*CommitTransaction) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*CommitTransaction) StatementType ¶
func (*CommitTransaction) StatementType() StatementType
StatementType implements the Statement interface.
func (*CommitTransaction) String ¶
func (n *CommitTransaction) String() string
type ComparisonExpr ¶
type ComparisonExpr struct { Operator ComparisonOperator Left, Right Expr // contains filtered or unexported fields }
ComparisonExpr represents a two-value comparison expression.
func NewTypedComparisonExpr ¶
func NewTypedComparisonExpr(op ComparisonOperator, left, right TypedExpr) *ComparisonExpr
NewTypedComparisonExpr returns a new ComparisonExpr that is verified to be well-typed.
func (*ComparisonExpr) Eval ¶
func (expr *ComparisonExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*ComparisonExpr) Format ¶
func (node *ComparisonExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ComparisonExpr) IsMixedTypeComparison ¶
func (node *ComparisonExpr) IsMixedTypeComparison() bool
IsMixedTypeComparison returns true when the two sides of a comparison operator have different types.
func (ComparisonExpr) ResolvedType ¶
func (ta ComparisonExpr) ResolvedType() Type
func (*ComparisonExpr) String ¶
func (node *ComparisonExpr) String() string
func (*ComparisonExpr) TypeCheck ¶
func (expr *ComparisonExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*ComparisonExpr) TypedLeft ¶
func (node *ComparisonExpr) TypedLeft() TypedExpr
TypedLeft returns the ComparisonExpr's left expression as a TypedExpr.
func (*ComparisonExpr) TypedRight ¶
func (node *ComparisonExpr) TypedRight() TypedExpr
TypedRight returns the ComparisonExpr's right expression as a TypedExpr.
func (*ComparisonExpr) Walk ¶
func (expr *ComparisonExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type ComparisonOperator ¶
type ComparisonOperator int
ComparisonOperator represents a binary operator.
const ( EQ ComparisonOperator = iota LT GT LE GE NE In NotIn Like NotLike ILike NotILike SimilarTo NotSimilarTo RegMatch NotRegMatch RegIMatch NotRegIMatch IsDistinctFrom IsNotDistinctFrom Is IsNot )
ComparisonExpr.Operator
func (ComparisonOperator) String ¶
func (i ComparisonOperator) String() string
type Constant ¶
type Constant interface { Expr // AvailableTypes returns the ordered set of types that the Constant is able to // be resolved into. The order of the type slice provides a notion of precedence, // with the first element in the ordering being the Constant's "natural type". AvailableTypes() []Type // ResolveAsType resolves the Constant as the Datum type specified, or returns an // error if the Constant could not be resolved as that type. The method should only // be passed a type returned from AvailableTypes and should never be called more than // once for a given Constant. ResolveAsType(*SemaContext, Type) (Datum, error) }
Constant is an constant literal expression which may be resolved to more than one type.
type ConstraintTableDef ¶
type ConstraintTableDef interface { TableDef // contains filtered or unexported methods }
ConstraintTableDef represents a constraint definition within a CREATE TABLE statement.
type ContainsWindowVisitor ¶
type ContainsWindowVisitor struct {
// contains filtered or unexported fields
}
ContainsWindowVisitor checks if walked expressions contain window functions.
func (*ContainsWindowVisitor) ContainsWindowFunc ¶
func (v *ContainsWindowVisitor) ContainsWindowFunc(expr Expr) bool
ContainsWindowFunc determines if an Expr contains a window function.
func (*ContainsWindowVisitor) VisitPost ¶
func (*ContainsWindowVisitor) VisitPost(expr Expr) Expr
VisitPost satisfies the Visitor interface.
type CopyFrom ¶
type CopyFrom struct { Table NormalizableTableName Columns UnresolvedNames Stdin bool }
CopyFrom represents a COPY FROM statement.
func (*CopyFrom) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*CopyFrom) StatementType ¶
func (*CopyFrom) StatementType() StatementType
StatementType implements the Statement interface.
type CreateDatabase ¶
CreateDatabase represents a CREATE DATABASE statement.
func (*CreateDatabase) Format ¶
func (node *CreateDatabase) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*CreateDatabase) StatementTag ¶
func (*CreateDatabase) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*CreateDatabase) StatementType ¶
func (*CreateDatabase) StatementType() StatementType
StatementType implements the Statement interface.
func (*CreateDatabase) String ¶
func (n *CreateDatabase) String() string
type CreateIndex ¶
type CreateIndex struct { Name Name Table NormalizableTableName Unique bool IfNotExists bool Columns IndexElemList // Extra columns to be stored together with the indexed ones as an optimization // for improved reading performance. Storing NameList Interleave *InterleaveDef }
CreateIndex represents a CREATE INDEX statement.
func (*CreateIndex) Format ¶
func (node *CreateIndex) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*CreateIndex) StatementTag ¶
func (*CreateIndex) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*CreateIndex) StatementType ¶
func (*CreateIndex) StatementType() StatementType
StatementType implements the Statement interface.
func (*CreateIndex) String ¶
func (n *CreateIndex) String() string
type CreateTable ¶
type CreateTable struct { IfNotExists bool Table NormalizableTableName Interleave *InterleaveDef Defs TableDefs AsSource *Select AsColumnNames NameList // Only to be used in conjunction with AsSource }
CreateTable represents a CREATE TABLE statement.
func (*CreateTable) As ¶
func (node *CreateTable) As() bool
As returns true if this table represents a CREATE TABLE ... AS statement, false otherwise.
func (*CreateTable) Format ¶
func (node *CreateTable) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*CreateTable) StatementTag ¶
func (*CreateTable) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*CreateTable) StatementType ¶
func (*CreateTable) StatementType() StatementType
StatementType implements the Statement interface.
func (*CreateTable) String ¶
func (n *CreateTable) String() string
type CreateUser ¶
CreateUser represents a CREATE USER statement.
func (*CreateUser) Format ¶
func (node *CreateUser) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*CreateUser) StatementTag ¶
func (*CreateUser) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*CreateUser) StatementType ¶
func (*CreateUser) StatementType() StatementType
StatementType implements the Statement interface.
func (*CreateUser) String ¶
func (n *CreateUser) String() string
type CreateView ¶
type CreateView struct { Name NormalizableTableName ColumnNames NameList AsSource *Select }
CreateView represents a CREATE VIEW statement.
func (*CreateView) Format ¶
func (node *CreateView) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*CreateView) StatementTag ¶
func (*CreateView) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*CreateView) StatementType ¶
func (*CreateView) StatementType() StatementType
StatementType implements the Statement interface.
func (*CreateView) String ¶
func (n *CreateView) String() string
type DArray ¶
type DArray []Datum
DArray is the array Datum. Currently, all arrays are text arrays. Any Datum inserted into a DArray are treated as text during serialization. This is probably sufficient to provide basic ORM (ActiveRecord) support, but we'll need to support different array types (e.g. int[]) when we implement persistent storage and other features of arrays.
func (*DArray) Eval ¶
func (t *DArray) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DArray) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DBool ¶
type DBool bool
DBool is the boolean Datum.
func MakeDBool ¶
MakeDBool converts its argument to a *DBool, returning either DBoolTrue or DBoolFalse.
func ParseDBool ¶
ParseDBool parses and returns the *DBool Datum value represented by the provided string, or an error if parsing is unsuccessful.
func (*DBool) Eval ¶
func (t *DBool) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DBool) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DBytes ¶
type DBytes string
DBytes is the bytes Datum. The underlying type is a string because we want the immutability, but this may contain arbitrary bytes.
func (*DBytes) Eval ¶
func (t *DBytes) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DBytes) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DCollatedString ¶
type DCollatedString struct { Contents string Locale string // contains filtered or unexported fields }
DCollatedString is the Datum for strings with a locale. The struct members are intended to be immutable.
func NewDCollatedString ¶
func NewDCollatedString(contents string, locale string, env *CollationEnvironment) *DCollatedString
NewDCollatedString is a helper routine to create a *DCollatedString. Panics if locale is invalid. Not safe for concurrent use.
func (*DCollatedString) Compare ¶
func (d *DCollatedString) Compare(other Datum) int
Compare implements the Datum interface.
func (*DCollatedString) Eval ¶
func (t *DCollatedString) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DCollatedString) Format ¶
func (d *DCollatedString) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*DCollatedString) HasNext ¶
func (*DCollatedString) HasNext() bool
HasNext implements the Datum interface.
func (*DCollatedString) HasPrev ¶
func (*DCollatedString) HasPrev() bool
HasPrev implements the Datum interface.
func (*DCollatedString) IsMax ¶
func (*DCollatedString) IsMax() bool
IsMax implements the Datum interface.
func (*DCollatedString) IsMin ¶
func (d *DCollatedString) IsMin() bool
IsMin implements the Datum interface.
func (*DCollatedString) Next ¶
func (d *DCollatedString) Next() Datum
Next implements the Datum interface.
func (*DCollatedString) Prev ¶
func (d *DCollatedString) Prev() Datum
Prev implements the Datum interface.
func (*DCollatedString) ResolvedType ¶
func (d *DCollatedString) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (*DCollatedString) Size ¶
func (d *DCollatedString) Size() uintptr
Size implements the Datum interface.
func (*DCollatedString) String ¶
func (node *DCollatedString) String() string
func (*DCollatedString) TypeCheck ¶
func (d *DCollatedString) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.
func (*DCollatedString) Walk ¶
func (expr *DCollatedString) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type DDate ¶
type DDate int64
DDate is the date Datum represented as the number of days after the Unix epoch.
func NewDDateFromTime ¶
NewDDateFromTime constructs a *DDate from a time.Time in the provided time zone.
func ParseDDate ¶
ParseDDate parses and returns the *DDate Datum value represented by the provided string in the provided location, or an error if parsing is unsuccessful.
func (*DDate) Eval ¶
func (t *DDate) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DDate) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DDecimal ¶
type DDecimal struct {
inf.Dec
}
DDecimal is the decimal Datum.
var DecimalOne DDecimal
DecimalOne represents the constant 1 as DECIMAL.
var DecimalZero DDecimal
DecimalZero represents the constant 0 as DECIMAL.
func ParseDDecimal ¶
ParseDDecimal parses and returns the *DDecimal Datum value represented by the provided string, or an error if parsing is unsuccessful.
func (*DDecimal) Eval ¶
func (t *DDecimal) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DDecimal) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DFloat ¶
type DFloat float64
DFloat is the float Datum.
func ParseDFloat ¶
ParseDFloat parses and returns the *DFloat Datum value represented by the provided string, or an error if parsing is unsuccessful.
func (*DFloat) Eval ¶
func (t *DFloat) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DFloat) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DInt ¶
type DInt int64
DInt is the int Datum.
func ParseDInt ¶
ParseDInt parses and returns the *DInt Datum value represented by the provided string, or an error if parsing is unsuccessful.
func (*DInt) Eval ¶
func (t *DInt) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DInt) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DInterval ¶
DInterval is the interval Datum.
func ParseDInterval ¶
ParseDInterval parses and returns the *DInterval Datum value represented by the provided string, or an error if parsing is unsuccessful.
func (*DInterval) Eval ¶
func (t *DInterval) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DInterval) Format ¶
Format implements the NodeFormatter interface. Example: "INTERVAL `1h2m`".
func (*DInterval) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
func (*DInterval) TypeCheck ¶
func (d *DInterval) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.
func (*DInterval) ValueAsString ¶
ValueAsString returns the interval as a string (e.g. "1h2m").
type DString ¶
type DString string
DString is the string Datum.
func NewDString ¶
NewDString is a helper routine to create a *DString initialized from its argument.
func (*DString) Eval ¶
func (t *DString) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DString) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type DTimestamp ¶
DTimestamp is the timestamp Datum.
func MakeDTimestamp ¶
func MakeDTimestamp(t time.Time, precision time.Duration) *DTimestamp
MakeDTimestamp creates a DTimestamp with specified precision.
func ParseDTimestamp ¶
func ParseDTimestamp(s string, precision time.Duration) (*DTimestamp, error)
ParseDTimestamp parses and returns the *DTimestamp Datum value represented by the provided string in UTC, or an error if parsing is unsuccessful.
func (*DTimestamp) Compare ¶
func (d *DTimestamp) Compare(other Datum) int
Compare implements the Datum interface.
func (*DTimestamp) Eval ¶
func (t *DTimestamp) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DTimestamp) Format ¶
func (d *DTimestamp) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*DTimestamp) HasNext ¶
func (*DTimestamp) HasNext() bool
HasNext implements the Datum interface.
func (*DTimestamp) HasPrev ¶
func (*DTimestamp) HasPrev() bool
HasPrev implements the Datum interface.
func (*DTimestamp) ResolvedType ¶
func (*DTimestamp) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (*DTimestamp) String ¶
func (node *DTimestamp) String() string
func (*DTimestamp) TypeCheck ¶
func (d *DTimestamp) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.
func (*DTimestamp) Walk ¶
func (expr *DTimestamp) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type DTimestampTZ ¶
DTimestampTZ is the timestamp Datum that is rendered with session offset.
func MakeDTimestampTZ ¶
func MakeDTimestampTZ(t time.Time, precision time.Duration) *DTimestampTZ
MakeDTimestampTZ creates a DTimestampTZ with specified precision.
func ParseDTimestampTZ ¶
func ParseDTimestampTZ( s string, loc *time.Location, precision time.Duration, ) (*DTimestampTZ, error)
ParseDTimestampTZ parses and returns the *DTimestampTZ Datum value represented by the provided string in the provided location, or an error if parsing is unsuccessful.
func (*DTimestampTZ) Compare ¶
func (d *DTimestampTZ) Compare(other Datum) int
Compare implements the Datum interface.
func (*DTimestampTZ) Eval ¶
func (t *DTimestampTZ) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DTimestampTZ) Format ¶
func (d *DTimestampTZ) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*DTimestampTZ) HasNext ¶
func (d *DTimestampTZ) HasNext() bool
HasNext implements the Datum interface.
func (*DTimestampTZ) HasPrev ¶
func (d *DTimestampTZ) HasPrev() bool
HasPrev implements the Datum interface.
func (*DTimestampTZ) IsMax ¶
func (d *DTimestampTZ) IsMax() bool
IsMax implements the Datum interface.
func (*DTimestampTZ) IsMin ¶
func (d *DTimestampTZ) IsMin() bool
IsMin implements the Datum interface.
func (*DTimestampTZ) Next ¶
func (d *DTimestampTZ) Next() Datum
Next implements the Datum interface.
func (*DTimestampTZ) Prev ¶
func (d *DTimestampTZ) Prev() Datum
Prev implements the Datum interface.
func (*DTimestampTZ) ResolvedType ¶
func (*DTimestampTZ) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (*DTimestampTZ) Size ¶
func (d *DTimestampTZ) Size() uintptr
Size implements the Datum interface.
func (*DTimestampTZ) String ¶
func (node *DTimestampTZ) String() string
func (*DTimestampTZ) TypeCheck ¶
func (d *DTimestampTZ) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.
func (*DTimestampTZ) Walk ¶
func (expr *DTimestampTZ) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type DTuple ¶
type DTuple []Datum
DTuple is the tuple Datum.
func (*DTuple) Eval ¶
func (t *DTuple) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*DTuple) Normalize ¶
func (d *DTuple) Normalize()
Normalize sorts and uniques the datum tuple.
func (*DTuple) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
func (*DTuple) SortedDifference ¶
SortedDifference finds the elements of d which are not in other, assuming that d and other are already sorted.
type DateColType ¶
type DateColType struct { }
DateColType represents a DATE type.
func (*DateColType) Format ¶
func (node *DateColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*DateColType) String ¶
func (node *DateColType) String() string
type Datum ¶
type Datum interface { TypedExpr // Compare returns -1 if the receiver is less than other, 0 if receiver is // equal to other and +1 if receiver is greater than other. // TODO(nvanbenschoten) Should we look into merging this with cmpOps? Compare(other Datum) int // HasPrev specifies if Prev() can be used to compute a previous value for // a datum. For example, DBytes doesn't support it (the previous for BB is BAZZZ..). HasPrev() bool // Prev returns the previous datum. If the receiver is "b" and the returned datum // is "a", then "a < b" and no other datum will compare such that "a < c < // b". // The return value is undefined if `IsMin()`. Prev() Datum // HasNext specifies if Next() can be used to compute a next value for a // datum. For example, DDecimal doesn't support it (the next for 1.0 is 1.00..1). HasNext() bool // Next returns the next datum. If the receiver is "a" and the returned datum // is "b", then "a < b" and no other datum will compare such that "a < c < // b". // The return value is undefined if `IsMax()`. Next() Datum // IsMax returns true if the datum is equal to the maximum value the datum // type can hold. IsMax() bool // IsMin returns true if the datum is equal to the minimum value the datum // type can hold. IsMin() bool // Size returns a lower bound on the total size of the receiver in bytes, // including memory that is pointed at (even if shared between Datum // instances) but excluding allocation overhead. // // It holds for every Datum d that d.Size() >= d.ResolvedType().Size(). Size() uintptr }
Datum represents a SQL value.
type Deallocate ¶
type Deallocate struct {
Name Name // empty for ALL
}
Deallocate represents a DEALLOCATE statement.
func (*Deallocate) Format ¶
func (node *Deallocate) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*Deallocate) StatementTag ¶
func (n *Deallocate) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*Deallocate) StatementType ¶
func (*Deallocate) StatementType() StatementType
StatementType implements the Statement interface.
func (*Deallocate) String ¶
func (n *Deallocate) String() string
type DecimalColType ¶
DecimalColType represents a DECIMAL or NUMERIC type.
func (*DecimalColType) Format ¶
func (node *DecimalColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*DecimalColType) String ¶
func (node *DecimalColType) String() string
type DefaultVal ¶
type DefaultVal struct{}
DefaultVal represents the DEFAULT expression.
func (DefaultVal) Eval ¶
func (expr DefaultVal) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (DefaultVal) Format ¶
func (node DefaultVal) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (DefaultVal) ResolvedType ¶
func (DefaultVal) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (DefaultVal) String ¶
func (node DefaultVal) String() string
func (DefaultVal) TypeCheck ¶
func (expr DefaultVal) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (DefaultVal) Walk ¶
func (expr DefaultVal) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type Delete ¶
type Delete struct { Table TableExpr Where *Where Returning ReturningExprs }
Delete represents a DELETE statement.
func (*Delete) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Delete) StatementType ¶
func (n *Delete) StatementType() StatementType
StatementType implements the Statement interface.
type DropBehavior ¶
type DropBehavior int
DropBehavior represents options for dropping schema elements.
const ( DropDefault DropBehavior = iota DropRestrict DropCascade )
DropBehavior values.
func (DropBehavior) String ¶
func (d DropBehavior) String() string
type DropDatabase ¶
DropDatabase represents a DROP DATABASE statement.
func (*DropDatabase) Format ¶
func (node *DropDatabase) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*DropDatabase) StatementTag ¶
func (*DropDatabase) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*DropDatabase) StatementType ¶
func (*DropDatabase) StatementType() StatementType
StatementType implements the Statement interface.
func (*DropDatabase) String ¶
func (n *DropDatabase) String() string
type DropIndex ¶
type DropIndex struct { IndexList TableNameWithIndexList IfExists bool DropBehavior DropBehavior }
DropIndex represents a DROP INDEX statement.
func (*DropIndex) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*DropIndex) StatementType ¶
func (*DropIndex) StatementType() StatementType
StatementType implements the Statement interface.
type DropTable ¶
type DropTable struct { Names TableNameReferences IfExists bool DropBehavior DropBehavior }
DropTable represents a DROP TABLE statement.
func (*DropTable) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*DropTable) StatementType ¶
func (*DropTable) StatementType() StatementType
StatementType implements the Statement interface.
type DropView ¶
type DropView struct { Names TableNameReferences IfExists bool DropBehavior DropBehavior }
DropView represents a DROP VIEW statement.
func (*DropView) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*DropView) StatementType ¶
func (*DropView) StatementType() StatementType
StatementType implements the Statement interface.
type EvalContext ¶
type EvalContext struct { NodeID roachpb.NodeID // Location references the *Location on the current Session. Location **time.Location // Database is the database in the current Session. Database string // SearchPath is the search path for databases used when encountering an // unqualified table name. Names in the search path are normalized already. // This must not be modified (this is shared from the session). SearchPath []string ReCache *RegexpCache // TODO(mjibson): remove prepareOnly in favor of a 2-step prepare-exec solution // that is also able to save the plan to skip work during the exec step. PrepareOnly bool // SkipNormalize indicates whether expressions should be normalized // (false) or not (true). It is set to true conditionally by // EXPLAIN(TYPES[, NORMALIZE]). SkipNormalize bool // contains filtered or unexported fields }
EvalContext defines the context in which to evaluate an expression, allowing the retrieval of state such as the node ID or statement start time.
func (*EvalContext) GetClusterTimestamp ¶
func (ctx *EvalContext) GetClusterTimestamp() *DDecimal
GetClusterTimestamp retrieves the current cluster timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.
func (*EvalContext) GetLocation ¶
func (ctx *EvalContext) GetLocation() *time.Location
GetLocation returns the session timezone.
func (*EvalContext) GetStmtTimestamp ¶
func (ctx *EvalContext) GetStmtTimestamp() time.Time
GetStmtTimestamp retrieves the current statement timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.
func (*EvalContext) GetTxnTimestamp ¶
func (ctx *EvalContext) GetTxnTimestamp(precision time.Duration) *DTimestampTZ
GetTxnTimestamp retrieves the current transaction timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.
func (*EvalContext) GetTxnTimestampNoZone ¶
func (ctx *EvalContext) GetTxnTimestampNoZone(precision time.Duration) *DTimestamp
GetTxnTimestampNoZone retrieves the current transaction timestamp as per the evaluation context. The timestamp is guaranteed to be nonzero.
func (*EvalContext) NormalizeExpr ¶
func (ctx *EvalContext) NormalizeExpr(typedExpr TypedExpr) (TypedExpr, error)
NormalizeExpr normalizes a typed expression, simplifying where possible, but guaranteeing that the result of evaluating the expression is unchanged and that resulting expression tree is still well-typed. Example normalizations:
(a) -> a a = 1 + 1 -> a = 2 a + 1 = 2 -> a = 1 a BETWEEN b AND c -> (a >= b) AND (a <= c) a NOT BETWEEN b AND c -> (a < b) OR (a > c)
func (*EvalContext) SetClusterTimestamp ¶
func (ctx *EvalContext) SetClusterTimestamp(ts hlc.Timestamp)
SetClusterTimestamp sets the corresponding timestamp in the EvalContext.
func (*EvalContext) SetStmtTimestamp ¶
func (ctx *EvalContext) SetStmtTimestamp(ts time.Time)
SetStmtTimestamp sets the corresponding timestamp in the EvalContext.
func (*EvalContext) SetTxnTimestamp ¶
func (ctx *EvalContext) SetTxnTimestamp(ts time.Time)
SetTxnTimestamp sets the corresponding timestamp in the EvalContext.
type Execute ¶
Execute represents an EXECUTE statement.
func (*Execute) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Execute) StatementType ¶
func (*Execute) StatementType() StatementType
StatementType implements the Statement interface.
type ExistsExpr ¶
type ExistsExpr struct { Subquery Expr // contains filtered or unexported fields }
ExistsExpr represents an EXISTS expression.
func (*ExistsExpr) Eval ¶
func (t *ExistsExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*ExistsExpr) Format ¶
func (node *ExistsExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (ExistsExpr) ResolvedType ¶
func (ta ExistsExpr) ResolvedType() Type
func (*ExistsExpr) String ¶
func (node *ExistsExpr) String() string
func (*ExistsExpr) TypeCheck ¶
func (expr *ExistsExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*ExistsExpr) Walk ¶
func (expr *ExistsExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type Explain ¶
Explain represents an EXPLAIN statement.
func (*Explain) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Explain) StatementType ¶
func (*Explain) StatementType() StatementType
StatementType implements the Statement interface.
type Expr ¶
type Expr interface { fmt.Stringer NodeFormatter // Walk recursively walks all children using WalkExpr. If any children are changed, it returns a // copy of this node updated to point to the new children. Otherwise the receiver is returned. // For childless (leaf) Exprs, its implementation is empty. Walk(Visitor) Expr // TypeCheck transforms the Expr into a well-typed TypedExpr, which further permits // evaluation and type introspection, or an error if the expression cannot be well-typed. // When type checking is complete, if no error was reported, the expression and all // sub-expressions will be guaranteed to be well-typed, meaning that the method effectively // maps the Expr tree into a TypedExpr tree. // // The ctx parameter defines the context in which to perform type checking. // The desired parameter hints the desired type that the method's caller wants from // the resulting TypedExpr. TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error) }
Expr represents an expression.
func ParseExprTraditional ¶
ParseExprTraditional is a short-hand for parseExprs([]string{sql}, Traditional)
func SimpleVisit ¶
func SimpleVisit(expr Expr, preFn SimpleVisitFn) (Expr, error)
SimpleVisit is a convenience wrapper for visitors that only have VisitPre code and don't return any results except an error. The given function is called in VisitPre for every node. The visitor stops as soon as an error is returned.
func StripParens ¶
StripParens strips any parentheses surrounding an expression and returns the inner expression. For instance:
1 -> 1 (1) -> 1
((1)) -> 1
type Exprs ¶
type Exprs []Expr
Exprs represents a list of value expressions. It's not a valid expression because it's not parenthesized.
func ParseExprsTraditional ¶
ParseExprsTraditional is a short-hand for parseExprs(sql, Traditional)
type FamilyTableDef ¶
FamilyTableDef represents a family definition within a CREATE TABLE statement.
type FloatColType ¶
FloatColType represents a REAL, DOUBLE or FLOAT type.
func (*FloatColType) Format ¶
func (node *FloatColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*FloatColType) String ¶
func (node *FloatColType) String() string
type FmtFlags ¶
type FmtFlags *fmtFlags
FmtFlags enables conditional formatting in the pretty-printer.
FmtQualify instructs the pretty-printer to qualify names with the table name.
FmtShowTypes instructs the pretty-printer to annotate expressions with their resolved types.
FmtSimple instructs the pretty-printer to produce a straightforward representation, ideally using SQL syntax that makes prettyprint+parse idempotent.
func FmtNormalizeTableNames ¶
func FmtNormalizeTableNames(fn func(*NormalizableTableName) *TableName) FmtFlags
FmtNormalizeTableNames returns FmtFlags that instructs the pretty-printer to normalize all table names using the provided function.
type ForeignKeyConstraintTableDef ¶
type ForeignKeyConstraintTableDef struct { Name Name Table NormalizableTableName FromCols NameList ToCols NameList }
ForeignKeyConstraintTableDef represents a FOREIGN KEY constraint in the AST.
type FuncExpr ¶
type FuncExpr struct { Func ResolvableFunctionReference Type funcType Exprs Exprs WindowDef *WindowDef // contains filtered or unexported fields }
FuncExpr represents a function call.
func (*FuncExpr) CopyNode ¶
CopyNode makes a copy of this Expr without recursing in any child Exprs.
func (*FuncExpr) Eval ¶
func (expr *FuncExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*FuncExpr) GetAggregateConstructor ¶
func (node *FuncExpr) GetAggregateConstructor() func() AggregateFunc
GetAggregateConstructor exposes the AggregateFunc field for use by the group node in package sql.
func (*FuncExpr) GetWindowConstructor ¶
func (node *FuncExpr) GetWindowConstructor() func() WindowFunc
GetWindowConstructor returns a window function constructor if the FuncExpr is a built-in window function.
func (*FuncExpr) IsImpure ¶
IsImpure returns whether the function application is impure, meaning that it potentially returns a different value when called in the same statement with the same parameters.
func (*FuncExpr) IsWindowFunctionApplication ¶
IsWindowFunctionApplication returns if the function is being applied as a window function.
func (FuncExpr) ResolvedType ¶
func (ta FuncExpr) ResolvedType() Type
type FunctionClass ¶
type FunctionClass int
FunctionClass specifies the class of the builtin function.
const ( // NormalClass is a standard builtin function. NormalClass FunctionClass = iota // AggregateClass is a builtin aggregate function. AggregateClass // WindowClass is a builtin window function. WindowClass )
type FunctionDefinition ¶
FunctionDefinition implements a reference to one or more function overloads for a built-in function.
func (*FunctionDefinition) Format ¶
func (fd *FunctionDefinition) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*FunctionDefinition) String ¶
func (fd *FunctionDefinition) String() string
type FunctionReference ¶
type FunctionReference interface { fmt.Stringer NodeFormatter // contains filtered or unexported methods }
FunctionReference is the common interface to UnresolvedName and QualifiedFunctionName.
type Grant ¶
type Grant struct { Privileges privilege.List Targets TargetList Grantees NameList }
Grant represents a GRANT statement.
func (*Grant) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Grant) StatementType ¶
func (*Grant) StatementType() StatementType
StatementType implements the Statement interface.
type Help ¶
type Help struct {
Name Name
}
Help represents a HELP statement.
func (*Help) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Help) StatementType ¶
func (*Help) StatementType() StatementType
StatementType implements the Statement interface.
type IfExpr ¶
IfExpr represents an IF expression.
func (*IfExpr) Eval ¶
func (expr *IfExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (IfExpr) ResolvedType ¶
func (ta IfExpr) ResolvedType() Type
func (*IfExpr) TypeCheck ¶
func (expr *IfExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*IfExpr) TypedCondExpr ¶
TypedCondExpr returns the IfExpr's Cond expression as a TypedExpr.
func (*IfExpr) TypedElseExpr ¶
TypedElseExpr returns the IfExpr's Else expression as a TypedExpr.
func (*IfExpr) TypedTrueExpr ¶
TypedTrueExpr returns the IfExpr's True expression as a TypedExpr.
type IndexElemList ¶
type IndexElemList []IndexElem
IndexElemList is list of IndexElem.
func NameListToIndexElems ¶
func NameListToIndexElems(lst NameList) IndexElemList
NameListToIndexElems converts a NameList to an IndexElemList with all members using the `DefaultDirection`.
type IndexHints ¶
IndexHints represents "@<index_name>" or "@{param[,param]}" where param is one of:
- FORCE_INDEX=<index_name>
- NO_INDEX_JOIN
It is used optionally after a table name in SELECT statements.
type IndexTableDef ¶
type IndexTableDef struct { Name Name Columns IndexElemList Storing NameList Interleave *InterleaveDef }
IndexTableDef represents an index definition within a CREATE TABLE statement.
type IndexedRow ¶
IndexedRow is a row with a corresponding index.
type IndexedVar ¶
type IndexedVar struct { Idx int // contains filtered or unexported fields }
IndexedVar is a VariableExpr that can be used as a leaf in expressions; it represents a dynamic value. It defers calls to TypeCheck, Eval, String to an IndexedVarContainer.
func (*IndexedVar) Eval ¶
func (v *IndexedVar) Eval(ctx *EvalContext) (Datum, error)
Eval is part of the TypedExpr interface.
func (*IndexedVar) Format ¶
func (v *IndexedVar) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*IndexedVar) ResolvedType ¶
func (v *IndexedVar) ResolvedType() Type
ResolvedType is part of the TypedExpr interface.
func (*IndexedVar) String ¶
func (node *IndexedVar) String() string
func (*IndexedVar) TypeCheck ¶
func (v *IndexedVar) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck is part of the Expr interface.
func (*IndexedVar) Variable ¶
func (*IndexedVar) Variable()
Variable is a dummy function part of the VariableExpr interface.
func (*IndexedVar) Walk ¶
func (v *IndexedVar) Walk(_ Visitor) Expr
Walk is part of the Expr interface.
type IndexedVarContainer ¶
type IndexedVarContainer interface { IndexedVarEval(idx int, ctx *EvalContext) (Datum, error) IndexedVarResolvedType(idx int) Type IndexedVarFormat(buf *bytes.Buffer, f FmtFlags, idx int) }
IndexedVarContainer provides the implementation of TypeCheck, Eval, and String for IndexedVars.
type IndexedVarHelper ¶
type IndexedVarHelper struct {
// contains filtered or unexported fields
}
IndexedVarHelper is a structure that helps with initialization of IndexVars.
func MakeIndexedVarHelper ¶
func MakeIndexedVarHelper(container IndexedVarContainer, numVars int) IndexedVarHelper
MakeIndexedVarHelper initializes an IndexedVarHelper structure.
func (*IndexedVarHelper) AssertSameContainer ¶
func (h *IndexedVarHelper) AssertSameContainer(ivar *IndexedVar)
AssertSameContainer checks that the indexed var refers to the same container.
func (*IndexedVarHelper) GetIndexedVars ¶
func (h *IndexedVarHelper) GetIndexedVars() []IndexedVar
GetIndexedVars transfers ownership of the array of initialized IndexedVars to the caller; unused vars are guaranteed to have an invalid index. The helper cannot be used any more after the ownership has been transferred.
func (*IndexedVarHelper) IndexedVar ¶
func (h *IndexedVarHelper) IndexedVar(idx int) *IndexedVar
IndexedVar returns an IndexedVar for the given index. The index must be valid.
func (*IndexedVarHelper) IndexedVarUsed ¶
func (h *IndexedVarHelper) IndexedVarUsed(idx int) bool
IndexedVarUsed returns true if IndexedVar() was called for the given index. The index must be valid.
func (*IndexedVarHelper) NumVars ¶
func (h *IndexedVarHelper) NumVars() int
NumVars returns the number of variables the IndexedVarHelper was initialized for.
type IndirectionExpr ¶
type IndirectionExpr struct { Expr Expr Indirection UnresolvedName // contains filtered or unexported fields }
IndirectionExpr represents a subscript expression.
func (*IndirectionExpr) CopyNode ¶
func (expr *IndirectionExpr) CopyNode() *IndirectionExpr
CopyNode makes a copy of this Expr without recursing in any child Exprs.
func (*IndirectionExpr) Eval ¶
func (expr *IndirectionExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*IndirectionExpr) Format ¶
func (node *IndirectionExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (IndirectionExpr) ResolvedType ¶
func (ta IndirectionExpr) ResolvedType() Type
func (*IndirectionExpr) String ¶
func (node *IndirectionExpr) String() string
func (*IndirectionExpr) TypeCheck ¶
func (expr *IndirectionExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*IndirectionExpr) Walk ¶
func (expr *IndirectionExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type Insert ¶
type Insert struct { Table TableExpr Columns UnresolvedNames Rows *Select OnConflict *OnConflict Returning ReturningExprs }
Insert represents an INSERT statement.
func (*Insert) DefaultValues ¶
DefaultValues returns true iff only default values are being inserted.
func (*Insert) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Insert) StatementType ¶
func (n *Insert) StatementType() StatementType
StatementType implements the Statement interface.
type IntColType ¶
IntColType represents an INT, INTEGER, SMALLINT or BIGINT type.
func (*IntColType) Format ¶
func (node *IntColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*IntColType) IsSerial ¶
func (node *IntColType) IsSerial() bool
IsSerial returns true when this column should be given a DEFAULT of a unique, incrementing function.
func (*IntColType) String ¶
func (node *IntColType) String() string
type InterleaveDef ¶
type InterleaveDef struct { Parent NormalizableTableName Fields NameList DropBehavior DropBehavior }
InterleaveDef represents an interleave definition within a CREATE TABLE or CREATE INDEX statement.
type IntervalColType ¶
type IntervalColType struct { }
IntervalColType represents an INTERVAL type
func (*IntervalColType) Format ¶
func (node *IntervalColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*IntervalColType) String ¶
func (node *IntervalColType) String() string
type IsAggregateVisitor ¶
type IsAggregateVisitor struct { Aggregated bool // contains filtered or unexported fields }
IsAggregateVisitor checks if walked expressions contain aggregate functions.
func (*IsAggregateVisitor) Reset ¶
func (v *IsAggregateVisitor) Reset()
Reset clear the IsAggregateVisitor's internal state.
func (*IsAggregateVisitor) VisitPost ¶
func (*IsAggregateVisitor) VisitPost(expr Expr) Expr
VisitPost satisfies the Visitor interface.
type IsOfTypeExpr ¶
type IsOfTypeExpr struct { Not bool Expr Expr Types []ColumnType // contains filtered or unexported fields }
IsOfTypeExpr represents an IS {,NOT} OF (type_list) expression.
func (*IsOfTypeExpr) Eval ¶
func (expr *IsOfTypeExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*IsOfTypeExpr) Format ¶
func (node *IsOfTypeExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (IsOfTypeExpr) ResolvedType ¶
func (ta IsOfTypeExpr) ResolvedType() Type
func (*IsOfTypeExpr) String ¶
func (node *IsOfTypeExpr) String() string
func (*IsOfTypeExpr) TypeCheck ¶
func (expr *IsOfTypeExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*IsOfTypeExpr) Walk ¶
func (expr *IsOfTypeExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type IsolationLevel ¶
type IsolationLevel int
IsolationLevel holds the isolation level for a transaction.
const ( UnspecifiedIsolation IsolationLevel = iota SnapshotIsolation SerializableIsolation )
IsolationLevel values
func (IsolationLevel) String ¶
func (i IsolationLevel) String() string
type JoinCond ¶
type JoinCond interface { NodeFormatter // contains filtered or unexported methods }
JoinCond represents a join condition.
type JoinTableExpr ¶
JoinTableExpr represents a TableExpr that's a JOIN operation.
func (*JoinTableExpr) Format ¶
func (node *JoinTableExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*JoinTableExpr) String ¶
func (node *JoinTableExpr) String() string
type MaxAggregate ¶
type MaxAggregate struct {
// contains filtered or unexported fields
}
MaxAggregate keeps track of the largest value passed to Add.
func (*MaxAggregate) Add ¶
func (a *MaxAggregate) Add(datum Datum)
Add sets the max to the larger of the current max or the passed datum.
func (*MaxAggregate) Result ¶
func (a *MaxAggregate) Result() Datum
Result returns the largest value passed to Add.
type MinAggregate ¶
type MinAggregate struct {
// contains filtered or unexported fields
}
MinAggregate keeps track of the smallest value passed to Add.
func (*MinAggregate) Add ¶
func (a *MinAggregate) Add(datum Datum)
Add sets the min to the smaller of the current min or the passed datum.
func (*MinAggregate) Result ¶
func (a *MinAggregate) Result() Datum
Result returns the smallest value passed to Add.
type Name ¶
type Name string
A Name is an SQL identifier.
type NameList ¶
type NameList []Name
A NameList is a list of identifiers.
type NamePart ¶
type NamePart interface { NodeFormatter // contains filtered or unexported methods }
NamePart is the interface for the sub-parts of an UnresolvedName or the Selector/Context members of ColumnItem and FunctionName.
type NameParts ¶
type NameParts []NamePart
NameParts represents a combination of names with array and sub-field subscripts.
type NamedArgTypes ¶
NamedArgTypes is very similar to ArgTypes except it allows keeping a string name for each argument as well and using those when printing the human-readable signature.
func (NamedArgTypes) Length ¶
func (a NamedArgTypes) Length() int
Length implements the typeList interface.
func (NamedArgTypes) String ¶
func (a NamedArgTypes) String() string
func (NamedArgTypes) Types ¶
func (a NamedArgTypes) Types() []Type
Types implements the typeList interface.
type NamedColumnQualification ¶
type NamedColumnQualification struct { Name Name Qualification ColumnQualification }
NamedColumnQualification wraps a NamedColumnQualification with a name.
type NaturalJoinCond ¶
type NaturalJoinCond struct{}
NaturalJoinCond represents a NATURAL join condition
type NodeFormatter ¶
type NodeFormatter interface { // Format performs pretty-printing towards a bytes buffer. The // flags argument influences the results. Format(buf *bytes.Buffer, flags FmtFlags) }
NodeFormatter is implemented by nodes that can be pretty-printed.
type NormalizableTableName ¶
type NormalizableTableName struct {
TableNameReference
}
NormalizableTableName implements an editable table name.
func (NormalizableTableName) Format ¶
func (nt NormalizableTableName) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*NormalizableTableName) Normalize ¶
func (nt *NormalizableTableName) Normalize() (*TableName, error)
Normalize checks if the table name is already normalized and normalizes it as necessary.
func (*NormalizableTableName) NormalizeWithDatabaseName ¶
func (nt *NormalizableTableName) NormalizeWithDatabaseName(database string) (*TableName, error)
NormalizeWithDatabaseName combines Normalize and QualifyWithDatabase.
func (NormalizableTableName) String ¶
func (nt NormalizableTableName) String() string
func (*NormalizableTableName) TableName ¶
func (nt *NormalizableTableName) TableName() *TableName
TableName asserts that the table name has been previously normalized.
type NotExpr ¶
type NotExpr struct { Expr Expr // contains filtered or unexported fields }
NotExpr represents a NOT expression.
func NewTypedNotExpr ¶
NewTypedNotExpr returns a new NotExpr that is verified to be well-typed.
func (*NotExpr) Eval ¶
func (expr *NotExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (NotExpr) ResolvedType ¶
func (ta NotExpr) ResolvedType() Type
func (*NotExpr) TypeCheck ¶
func (expr *NotExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*NotExpr) TypedInnerExpr ¶
TypedInnerExpr returns the NotExpr's inner expression as a TypedExpr.
type NotNullConstraint ¶
type NotNullConstraint struct{}
NotNullConstraint represents NOT NULL on a column.
type NullIfExpr ¶
NullIfExpr represents a NULLIF expression.
func (*NullIfExpr) Eval ¶
func (expr *NullIfExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*NullIfExpr) Format ¶
func (node *NullIfExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (NullIfExpr) ResolvedType ¶
func (ta NullIfExpr) ResolvedType() Type
func (*NullIfExpr) String ¶
func (node *NullIfExpr) String() string
func (*NullIfExpr) TypeCheck ¶
func (expr *NullIfExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*NullIfExpr) Walk ¶
func (expr *NullIfExpr) Walk(v Visitor) Expr
Walk implements the Expr interface.
type Nullability ¶
type Nullability int
Nullability represents either NULL, NOT NULL or an unspecified value (silent NULL).
const ( NotNull Nullability = iota Null SilentNull )
The values for NullType.
type NumVal ¶
type NumVal struct { constant.Value // We preserve the "original" string representation (before folding). OrigString string // contains filtered or unexported fields }
NumVal represents a constant numeric value.
func (*NumVal) AvailableTypes ¶
AvailableTypes implements the Constant interface.
func (*NumVal) ResolveAsType ¶
func (expr *NumVal) ResolveAsType(ctx *SemaContext, typ Type) (Datum, error)
ResolveAsType implements the Constant interface.
type OnConflict ¶
type OnConflict struct { Columns NameList Exprs UpdateExprs Where *Where DoNothing bool }
OnConflict represents an `ON CONFLICT (columns) DO UPDATE SET exprs WHERE where` clause.
The zero value for OnConflict is used to signal the UPSERT short form, which uses the primary key for as the conflict index and the values being inserted for Exprs.
func (*OnConflict) IsUpsertAlias ¶
func (oc *OnConflict) IsUpsertAlias() bool
IsUpsertAlias returns true if the UPSERT syntactic sugar was used.
type OrExpr ¶
type OrExpr struct {
Left, Right Expr
// contains filtered or unexported fields
}
OrExpr represents an OR expression.
func NewTypedOrExpr ¶
NewTypedOrExpr returns a new OrExpr that is verified to be well-typed.
func (*OrExpr) Eval ¶
func (expr *OrExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (OrExpr) ResolvedType ¶
func (ta OrExpr) ResolvedType() Type
func (*OrExpr) TypeCheck ¶
func (expr *OrExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*OrExpr) TypedRight ¶
TypedRight returns the OrExpr's right expression as a TypedExpr.
type ParenExpr ¶
type ParenExpr struct { Expr Expr // contains filtered or unexported fields }
ParenExpr represents a parenthesized expression.
func (*ParenExpr) Eval ¶
func (expr *ParenExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (ParenExpr) ResolvedType ¶
func (ta ParenExpr) ResolvedType() Type
func (*ParenExpr) TypeCheck ¶
func (expr *ParenExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*ParenExpr) TypedInnerExpr ¶
TypedInnerExpr returns the ParenExpr's inner expression as a TypedExpr.
type ParenSelect ¶
type ParenSelect struct {
Select *Select
}
ParenSelect represents a parenthesized SELECT/UNION/VALUES statement.
func (*ParenSelect) Format ¶
func (node *ParenSelect) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ParenSelect) StatementTag ¶
func (*ParenSelect) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ParenSelect) StatementType ¶
func (*ParenSelect) StatementType() StatementType
StatementType implements the Statement interface.
func (*ParenSelect) String ¶
func (n *ParenSelect) String() string
func (*ParenSelect) WalkStmt ¶
func (stmt *ParenSelect) WalkStmt(v Visitor) Statement
WalkStmt is part of the WalkableStmt interface.
type ParenTableExpr ¶
type ParenTableExpr struct {
Expr TableExpr
}
ParenTableExpr represents a parenthesized TableExpr.
func (*ParenTableExpr) Format ¶
func (node *ParenTableExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ParenTableExpr) String ¶
func (node *ParenTableExpr) String() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser wraps a scanner, parser and other utilities present in the parser package.
func (*Parser) AggregateInExpr ¶
AggregateInExpr determines if an Expr contains an aggregate function.
func (*Parser) AssertNoAggregationOrWindowing ¶
AssertNoAggregationOrWindowing checks if the provided expression contains either aggregate functions or window functions, returning an error in either case.
func (*Parser) IsAggregate ¶
func (p *Parser) IsAggregate(n *SelectClause, searchPath []string) bool
IsAggregate determines if SelectClause contains an aggregate function.
func (*Parser) NormalizeExpr ¶
func (p *Parser) NormalizeExpr(ctx *EvalContext, typedExpr TypedExpr) (TypedExpr, error)
NormalizeExpr is wrapper around ctx.NormalizeExpr which avoids allocation of a normalizeVisitor.
func (*Parser) Parse ¶
func (p *Parser) Parse(sql string, syntax Syntax) (stmts StatementList, err error)
Parse parses the sql and returns a list of statements.
func (*Parser) WindowFuncInExpr ¶
WindowFuncInExpr determines if an Expr contains a window function, using the Parser's embedded visitor.
func (*Parser) WindowFuncInExprs ¶
WindowFuncInExprs determines if any of the provided TypedExpr contains a window function, using the Parser's embedded visitor.
type Placeholder ¶
type Placeholder struct { Name string // contains filtered or unexported fields }
Placeholder represents a named placeholder.
func NewPlaceholder ¶
func NewPlaceholder(name string) *Placeholder
NewPlaceholder allocates a Placeholder.
func (*Placeholder) Eval ¶
func (node *Placeholder) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*Placeholder) Format ¶
func (node *Placeholder) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*Placeholder) ResolvedType ¶
func (node *Placeholder) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (*Placeholder) String ¶
func (node *Placeholder) String() string
func (*Placeholder) TypeCheck ¶
func (expr *Placeholder) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*Placeholder) Variable ¶
func (*Placeholder) Variable()
Variable implements the VariableExpr interface.
func (*Placeholder) Walk ¶
func (expr *Placeholder) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type PlaceholderInfo ¶
type PlaceholderInfo struct { Values QueryArguments Types PlaceholderTypes }
PlaceholderInfo defines the interface to SQL placeholders.
func NewPlaceholderInfo ¶
func NewPlaceholderInfo() *PlaceholderInfo
NewPlaceholderInfo constructs an empty PlaceholderInfo.
func (*PlaceholderInfo) AssertAllAssigned ¶
func (p *PlaceholderInfo) AssertAllAssigned() error
AssertAllAssigned ensures that all placeholders that are used also have a value assigned.
func (*PlaceholderInfo) Assign ¶
func (p *PlaceholderInfo) Assign(src *PlaceholderInfo)
Assign resets the PlaceholderInfo to the contents of src. If src is nil, the map is cleared.
func (*PlaceholderInfo) Clear ¶
func (p *PlaceholderInfo) Clear()
Clear resets the placeholder info map.
func (*PlaceholderInfo) FillUnassigned ¶
func (p *PlaceholderInfo) FillUnassigned()
FillUnassigned sets all unsassigned placeholders to NULL.
func (*PlaceholderInfo) IsUnresolvedPlaceholder ¶
func (p *PlaceholderInfo) IsUnresolvedPlaceholder(expr Expr) bool
IsUnresolvedPlaceholder returns whether expr is an unresolved placeholder. In other words, it returns whether the provided expression is a placeholder expression or a placeholder expression within nested parentheses, and if so, whether the placeholder's type remains unset in the PlaceholderInfo.
func (*PlaceholderInfo) SetType ¶
func (p *PlaceholderInfo) SetType(name string, typ Type) error
SetType assignes a known type to a placeholder. Reports an error if another type was previously assigned.
func (*PlaceholderInfo) SetTypes ¶
func (p *PlaceholderInfo) SetTypes(src PlaceholderTypes)
SetTypes resets the type and values in the map and replaces the types map by an alias to src. If src is nil, the map is cleared. The types map is aliased because the invoking code from pgwire/v3.go for sql.Prepare needs to receive the updated type assignments after Prepare completes.
func (*PlaceholderInfo) SetValue ¶
func (p *PlaceholderInfo) SetValue(name string, val Datum)
SetValue assigns a known value to a placeholder. If no type is known yet, it is inferred from the assigned value.
type PlaceholderTypes ¶
PlaceholderTypes relates placeholder names to their resolved type.
func (PlaceholderTypes) ProcessPlaceholderAnnotations ¶
func (p PlaceholderTypes) ProcessPlaceholderAnnotations(stmt Statement) error
ProcessPlaceholderAnnotations performs an order-independent global traversal of the provided Statement, annotating all placeholders with a type in either of the following situations.
- the placeholder is the subject of an explicit type annotation in at least one of its occurrences. If it is subject to multiple explicit type annotations where the types are not all in agreement, or if the placeholder already has an inferred type in the placeholder map which conflicts with the explicit type annotation type, an error will be thrown.
- the placeholder is the subject to an implicit type annotation, meaning that it is not subject to an explicit type annotation, and that in all occurrences of the placeholder, it is subject to a cast to the same type. If it is subject to casts of multiple types, no error will be thrown, but the placeholder type will not be inferred. If a type has already been assigned for the placeholder in the placeholder map, no error will be thrown, and the placeholder will keep it's previously inferred type.
TODO(nvanbenschoten) Can this visitor and map be preallocated (like normalizeVisitor)?
type Prepare ¶
type Prepare struct { Name Name Types []ColumnType Statement Statement }
Prepare represents a PREPARE statement.
func (*Prepare) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Prepare) StatementType ¶
func (*Prepare) StatementType() StatementType
StatementType implements the Statement interface.
type PrimaryKeyConstraint ¶
type PrimaryKeyConstraint struct{}
PrimaryKeyConstraint represents NULL on a column.
type QueryArguments ¶
QueryArguments relates placeholder names to their provided query argument.
type RangeCond ¶
type RangeCond struct { Not bool Left Expr From, To Expr // contains filtered or unexported fields }
RangeCond represents a BETWEEN or a NOT BETWEEN expression.
func (*RangeCond) Eval ¶
func (expr *RangeCond) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (RangeCond) ResolvedType ¶
func (ta RangeCond) ResolvedType() Type
func (*RangeCond) TypeCheck ¶
func (expr *RangeCond) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
type RegexpCache ¶
type RegexpCache struct {
// contains filtered or unexported fields
}
A RegexpCache is a cache used to store compiled regular expressions. The cache is safe for concurrent use by multiple goroutines. It is also safe to use the cache through a nil reference, where it will act like a valid cache with no capacity.
func NewRegexpCache ¶
func NewRegexpCache(size int) *RegexpCache
NewRegexpCache creates a new RegexpCache of the given size. The underlying cache internally uses a hash map, so lookups are cheap.
func (*RegexpCache) GetRegexp ¶
func (rc *RegexpCache) GetRegexp(key regexpCacheKey) (*regexp.Regexp, error)
GetRegexp consults the cache for the regular expressions stored for the given key, compiling the key's pattern if it is not already in the cache.
func (*RegexpCache) Len ¶
func (rc *RegexpCache) Len() int
Len returns the number of compiled regular expressions in the cache.
type ReleaseSavepoint ¶
type ReleaseSavepoint struct {
Savepoint string
}
ReleaseSavepoint represents a RELEASE SAVEPOINT <name> statement.
func (*ReleaseSavepoint) Format ¶
func (node *ReleaseSavepoint) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ReleaseSavepoint) StatementTag ¶
func (*ReleaseSavepoint) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ReleaseSavepoint) StatementType ¶
func (*ReleaseSavepoint) StatementType() StatementType
StatementType implements the Statement interface.
func (*ReleaseSavepoint) String ¶
func (n *ReleaseSavepoint) String() string
type RenameColumn ¶
type RenameColumn struct { Table NormalizableTableName Name Name NewName Name // IfExists refers to the table, not the column. IfExists bool }
RenameColumn represents a RENAME COLUMN statement.
func (*RenameColumn) Format ¶
func (node *RenameColumn) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*RenameColumn) StatementTag ¶
func (*RenameColumn) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*RenameColumn) StatementType ¶
func (*RenameColumn) StatementType() StatementType
StatementType implements the Statement interface.
func (*RenameColumn) String ¶
func (n *RenameColumn) String() string
type RenameDatabase ¶
RenameDatabase represents a RENAME DATABASE statement.
func (*RenameDatabase) Format ¶
func (node *RenameDatabase) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*RenameDatabase) StatementTag ¶
func (*RenameDatabase) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*RenameDatabase) StatementType ¶
func (*RenameDatabase) StatementType() StatementType
StatementType implements the Statement interface.
func (*RenameDatabase) String ¶
func (n *RenameDatabase) String() string
type RenameIndex ¶
type RenameIndex struct { Index *TableNameWithIndex NewName Name IfExists bool }
RenameIndex represents a RENAME INDEX statement.
func (*RenameIndex) Format ¶
func (node *RenameIndex) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*RenameIndex) StatementTag ¶
func (*RenameIndex) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*RenameIndex) StatementType ¶
func (*RenameIndex) StatementType() StatementType
StatementType implements the Statement interface.
func (*RenameIndex) String ¶
func (n *RenameIndex) String() string
type RenameTable ¶
type RenameTable struct { Name NormalizableTableName NewName NormalizableTableName IfExists bool IsView bool }
RenameTable represents a RENAME TABLE or RENAME VIEW statement. Whether the user has asked to rename a table or view is indicated by the IsView field.
func (*RenameTable) Format ¶
func (node *RenameTable) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*RenameTable) StatementTag ¶
func (n *RenameTable) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*RenameTable) StatementType ¶
func (*RenameTable) StatementType() StatementType
StatementType implements the Statement interface.
func (*RenameTable) String ¶
func (n *RenameTable) String() string
type ResolvableFunctionReference ¶
type ResolvableFunctionReference struct {
FunctionReference
}
ResolvableFunctionReference implements the editable reference cell of a FuncExpr. The FunctionRerence is updated by the Normalize() method.
func (ResolvableFunctionReference) Format ¶
func (fn ResolvableFunctionReference) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ResolvableFunctionReference) Resolve ¶
func (fn *ResolvableFunctionReference) Resolve(searchPath []string) (*FunctionDefinition, error)
Resolve checks if the function name is already resolved and resolves it as necessary.
func (ResolvableFunctionReference) String ¶
func (fn ResolvableFunctionReference) String() string
type ReturningExprs ¶
type ReturningExprs SelectExprs
ReturningExprs represents RETURNING expressions.
func (ReturningExprs) Format ¶
func (r ReturningExprs) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (ReturningExprs) StatementType ¶
func (r ReturningExprs) StatementType() StatementType
StatementType implements the Statement interface.
type Revoke ¶
type Revoke struct { Privileges privilege.List Targets TargetList Grantees NameList }
Revoke represents a REVOKE statements. PrivilegeList and TargetList are defined in grant.go
func (*Revoke) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Revoke) StatementType ¶
func (*Revoke) StatementType() StatementType
StatementType implements the Statement interface.
type RollbackToSavepoint ¶
type RollbackToSavepoint struct {
Savepoint string
}
RollbackToSavepoint represents a ROLLBACK TO SAVEPOINT <name> statement.
func (*RollbackToSavepoint) Format ¶
func (node *RollbackToSavepoint) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*RollbackToSavepoint) StatementTag ¶
func (*RollbackToSavepoint) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*RollbackToSavepoint) StatementType ¶
func (*RollbackToSavepoint) StatementType() StatementType
StatementType implements the Statement interface.
func (*RollbackToSavepoint) String ¶
func (n *RollbackToSavepoint) String() string
type RollbackTransaction ¶
type RollbackTransaction struct{}
RollbackTransaction represents a ROLLBACK statement.
func (*RollbackTransaction) Format ¶
func (node *RollbackTransaction) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*RollbackTransaction) StatementTag ¶
func (*RollbackTransaction) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*RollbackTransaction) StatementType ¶
func (*RollbackTransaction) StatementType() StatementType
StatementType implements the Statement interface.
func (*RollbackTransaction) String ¶
func (n *RollbackTransaction) String() string
type Savepoint ¶
type Savepoint struct {
Name string
}
Savepoint represents a SAVEPOINT <name> statement.
func (*Savepoint) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Savepoint) StatementType ¶
func (*Savepoint) StatementType() StatementType
StatementType implements the Statement interface.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner lexes SQL statements.
func MakeScanner ¶
MakeScanner makes a Scanner from str.
type Select ¶
type Select struct { Select SelectStatement OrderBy OrderBy Limit *Limit }
Select represents a SelectStatement with an ORDER and/or LIMIT.
func (*Select) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Select) StatementType ¶
func (*Select) StatementType() StatementType
StatementType implements the Statement interface.
type SelectClause ¶
type SelectClause struct { Distinct bool Exprs SelectExprs From *From Where *Where GroupBy GroupBy Having *Where Window Window Lock string // contains filtered or unexported fields }
SelectClause represents a SELECT statement.
func (*SelectClause) CopyNode ¶
func (stmt *SelectClause) CopyNode() *SelectClause
CopyNode makes a copy of this Expr without recursing in any child Exprs.
func (*SelectClause) Format ¶
func (node *SelectClause) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*SelectClause) StatementTag ¶
func (*SelectClause) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*SelectClause) StatementType ¶
func (*SelectClause) StatementType() StatementType
StatementType implements the Statement interface.
func (*SelectClause) String ¶
func (n *SelectClause) String() string
func (*SelectClause) WalkStmt ¶
func (stmt *SelectClause) WalkStmt(v Visitor) Statement
WalkStmt is part of the WalkableStmt interface.
type SelectExpr ¶
SelectExpr represents a SELECT expression.
func (SelectExpr) Format ¶
func (node SelectExpr) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*SelectExpr) NormalizeTopLevelVarName ¶
func (node *SelectExpr) NormalizeTopLevelVarName() error
NormalizeTopLevelVarName preemptively expands any UnresolvedName at the top level of the expression into a VarName. This is meant to catch stars so that sql.checkRenderStar() can see it prior to other expression transformations.
type SelectStatement ¶
type SelectStatement interface { Statement // contains filtered or unexported methods }
SelectStatement any SELECT statement.
type SemaContext ¶
type SemaContext struct { // Placeholders relates placeholder names to their type and, later, value. Placeholders *PlaceholderInfo // Location references the *Location on the current Session. Location **time.Location // SearchPath indicates where to search for unqualified function // names. The path elements must be normalized via Name.Normalize() // already. SearchPath []string }
SemaContext defines the context in which to perform semantic analysis on an expression syntax tree.
func MakeSemaContext ¶
func MakeSemaContext() SemaContext
MakeSemaContext initializes a simple SemaContext suitable for "lightweight" type checking such as the one performed for default expressions.
type Set ¶
Set represents a SET statement.
func (*Set) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Set) StatementType ¶
func (*Set) StatementType() StatementType
StatementType implements the Statement interface.
type SetDefaultIsolation ¶
type SetDefaultIsolation struct {
Isolation IsolationLevel
}
SetDefaultIsolation represents a SET SESSION CHARACTERISTICS AS TRANSACTION statement.
func (*SetDefaultIsolation) Format ¶
func (node *SetDefaultIsolation) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*SetDefaultIsolation) StatementTag ¶
func (*SetDefaultIsolation) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*SetDefaultIsolation) StatementType ¶
func (*SetDefaultIsolation) StatementType() StatementType
StatementType implements the Statement interface.
func (*SetDefaultIsolation) String ¶
func (n *SetDefaultIsolation) String() string
type SetTimeZone ¶
type SetTimeZone struct {
Value Expr
}
SetTimeZone represents a SET TIME ZONE statement.
func (*SetTimeZone) Format ¶
func (node *SetTimeZone) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*SetTimeZone) StatementTag ¶
func (*SetTimeZone) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*SetTimeZone) StatementType ¶
func (*SetTimeZone) StatementType() StatementType
StatementType implements the Statement interface.
func (*SetTimeZone) String ¶
func (n *SetTimeZone) String() string
type SetTransaction ¶
type SetTransaction struct { Isolation IsolationLevel UserPriority UserPriority }
SetTransaction represents a SET TRANSACTION statement.
func (*SetTransaction) Format ¶
func (node *SetTransaction) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*SetTransaction) StatementTag ¶
func (*SetTransaction) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*SetTransaction) StatementType ¶
func (*SetTransaction) StatementType() StatementType
StatementType implements the Statement interface.
func (*SetTransaction) String ¶
func (n *SetTransaction) String() string
type Show ¶
type Show struct {
Name string
}
Show represents a SHOW statement.
func (*Show) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Show) StatementType ¶
func (*Show) StatementType() StatementType
StatementType implements the Statement interface.
type ShowColumns ¶
type ShowColumns struct {
Table NormalizableTableName
}
ShowColumns represents a SHOW COLUMNS statement.
func (*ShowColumns) Format ¶
func (node *ShowColumns) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ShowColumns) StatementTag ¶
func (*ShowColumns) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ShowColumns) StatementType ¶
func (*ShowColumns) StatementType() StatementType
StatementType implements the Statement interface.
func (*ShowColumns) String ¶
func (n *ShowColumns) String() string
type ShowConstraints ¶
type ShowConstraints struct {
Table NormalizableTableName
}
ShowConstraints represents a SHOW CONSTRAINTS statement.
func (*ShowConstraints) Format ¶
func (node *ShowConstraints) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ShowConstraints) StatementTag ¶
func (*ShowConstraints) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ShowConstraints) StatementType ¶
func (*ShowConstraints) StatementType() StatementType
StatementType implements the Statement interface.
func (*ShowConstraints) String ¶
func (n *ShowConstraints) String() string
type ShowCreateTable ¶
type ShowCreateTable struct {
Table NormalizableTableName
}
ShowCreateTable represents a SHOW CREATE TABLE statement.
func (*ShowCreateTable) Format ¶
func (node *ShowCreateTable) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ShowCreateTable) StatementTag ¶
func (*ShowCreateTable) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ShowCreateTable) StatementType ¶
func (*ShowCreateTable) StatementType() StatementType
StatementType implements the Statement interface.
func (*ShowCreateTable) String ¶
func (n *ShowCreateTable) String() string
type ShowCreateView ¶
type ShowCreateView struct {
View NormalizableTableName
}
ShowCreateView represents a SHOW CREATE VIEW statement.
func (*ShowCreateView) Format ¶
func (node *ShowCreateView) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ShowCreateView) StatementTag ¶
func (*ShowCreateView) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ShowCreateView) StatementType ¶
func (*ShowCreateView) StatementType() StatementType
StatementType implements the Statement interface.
func (*ShowCreateView) String ¶
func (n *ShowCreateView) String() string
type ShowDatabases ¶
type ShowDatabases struct { }
ShowDatabases represents a SHOW DATABASES statement.
func (*ShowDatabases) Format ¶
func (node *ShowDatabases) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ShowDatabases) StatementTag ¶
func (*ShowDatabases) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ShowDatabases) StatementType ¶
func (*ShowDatabases) StatementType() StatementType
StatementType implements the Statement interface.
func (*ShowDatabases) String ¶
func (n *ShowDatabases) String() string
type ShowGrants ¶
type ShowGrants struct { Targets *TargetList Grantees NameList }
ShowGrants represents a SHOW GRANTS statement. TargetList is defined in grant.go.
func (*ShowGrants) Format ¶
func (node *ShowGrants) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ShowGrants) StatementTag ¶
func (*ShowGrants) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ShowGrants) StatementType ¶
func (*ShowGrants) StatementType() StatementType
StatementType implements the Statement interface.
func (*ShowGrants) String ¶
func (n *ShowGrants) String() string
type ShowIndex ¶
type ShowIndex struct {
Table NormalizableTableName
}
ShowIndex represents a SHOW INDEX statement.
func (*ShowIndex) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*ShowIndex) StatementType ¶
func (*ShowIndex) StatementType() StatementType
StatementType implements the Statement interface.
type ShowTables ¶
type ShowTables struct {
Database Name
}
ShowTables represents a SHOW TABLES statement.
func (*ShowTables) Format ¶
func (node *ShowTables) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*ShowTables) StatementTag ¶
func (*ShowTables) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*ShowTables) StatementType ¶
func (*ShowTables) StatementType() StatementType
StatementType implements the Statement interface.
func (*ShowTables) String ¶
func (n *ShowTables) String() string
type ShowUsers ¶
type ShowUsers struct { }
ShowUsers represents a SHOW USERS statement.
func (*ShowUsers) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*ShowUsers) StatementType ¶
func (*ShowUsers) StatementType() StatementType
StatementType implements the Statement interface.
type SimpleVisitFn ¶
SimpleVisitFn is a function that is run for every node in the VisitPre stage; see SimpleVisit.
type Split ¶
type Split struct { Table NormalizableTableName Index *TableNameWithIndex Exprs Exprs }
Split represents a SPLIT statement.
func (*Split) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Split) StatementType ¶
func (*Split) StatementType() StatementType
StatementType implements the Statement interface.
type StarDatum ¶
type StarDatum struct{}
StarDatum is a VariableExpr implementation used as a dummy argument for the special case COUNT(*). This ends up being processed correctly by the count aggregator since it is not DNull. Other instances of '*' as render expressions are handled by expandStar().
We need to implement enough functionality to satisfy the type checker and to allow the intermediate rendering of the value (before the group aggregation).
func (*StarDatum) Eval ¶
func (*StarDatum) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*StarDatum) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
func (*StarDatum) TypeCheck ¶
func (s *StarDatum) TypeCheck(_ *SemaContext, _ Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
type Statement ¶
type Statement interface { fmt.Stringer NodeFormatter StatementType() StatementType // StatementTag is a short string identifying the type of statement // (usually a single verb). This is different than the Stringer output, // which is the actual statement (including args). // TODO(dt): Currently tags are always pg-compatible in the future it // might make sense to pass a tag format specifier. StatementTag() string }
Statement represents a statement.
func ParseOneTraditional ¶
ParseOneTraditional is short-hand for ParseOne(sql, Traditional)
func WalkStmt ¶
WalkStmt walks the entire parsed stmt calling WalkExpr on each expression, and replacing each expression with the one returned by WalkExpr.
NOTE: Beware that WalkStmt does not necessarily traverse all parts of a statement by itself. For example, it will not walk into Subquery nodes within a FROM clause or into a JoinCond. Walk's logic is pretty interdependent with the logic for constructing a query plan.
type StatementList ¶
type StatementList []Statement
StatementList is a list of statements.
func (StatementList) Format ¶
func (l StatementList) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (StatementList) String ¶
func (l StatementList) String() string
type StatementType ¶
type StatementType int
StatementType is the enumerated type for Statement return styles on the wire.
const ( // Ack indicates that the statement does not have a meaningful // return. Examples include SET, BEGIN, COMMIT. Ack StatementType = iota // DDL indicates that the statement mutates the database schema. DDL // RowsAffected indicates that the statement returns the count of // affected rows. RowsAffected // Rows indicates that the statement returns the affected rows after // the statement was applied. Rows // CopyIn indicates a COPY FROM statement. CopyIn // Unknown indicates that the statement does not have a known // return style at the time of parsing. This is not first in the // enumeration because it is more convenient to have Ack as a zero // value, and because the use of Unknown should be an explicit choice. // The primary example of this statement type is EXECUTE, where the // statement type depends on the statement type of the prepared statement // being executed. Unknown )
type StrVal ¶
type StrVal struct {
// contains filtered or unexported fields
}
StrVal represents a constant string value.
func (*StrVal) AvailableTypes ¶
AvailableTypes implements the Constant interface.
func (*StrVal) ResolveAsType ¶
func (expr *StrVal) ResolveAsType(ctx *SemaContext, typ Type) (Datum, error)
ResolveAsType implements the Constant interface.
type StringColType ¶
StringColType represents a STRING, CHAR or VARCHAR type.
func (*StringColType) Format ¶
func (node *StringColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*StringColType) String ¶
func (node *StringColType) String() string
type Subquery ¶
type Subquery struct {
Select SelectStatement
}
Subquery represents a subquery.
func (*Subquery) Eval ¶
func (expr *Subquery) Eval(_ *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*Subquery) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
func (*Subquery) TypeCheck ¶
func (expr *Subquery) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
type TCollatedString ¶
type TCollatedString struct {
Locale string
}
TCollatedString is the type of strings with a locale.
func (TCollatedString) Equal ¶
func (t TCollatedString) Equal(other Type) bool
Equal implements the Type interface.
func (TCollatedString) FamilyEqual ¶
func (TCollatedString) FamilyEqual(other Type) bool
FamilyEqual implements the Type interface.
func (TCollatedString) IsAmbiguous ¶
func (t TCollatedString) IsAmbiguous() bool
IsAmbiguous implements the Type interface.
func (TCollatedString) Size ¶
func (TCollatedString) Size() (uintptr, bool)
Size implements the Type interface.
func (TCollatedString) String ¶
func (t TCollatedString) String() string
String implements the fmt.Stringer interface.
type TPlaceholder ¶
type TPlaceholder struct {
Name string
}
TPlaceholder is the type of a placeholder.
func (TPlaceholder) Equal ¶
func (t TPlaceholder) Equal(other Type) bool
Equal implements the Type interface.
func (TPlaceholder) FamilyEqual ¶
func (TPlaceholder) FamilyEqual(other Type) bool
FamilyEqual implements the Type interface.
func (TPlaceholder) IsAmbiguous ¶
func (TPlaceholder) IsAmbiguous() bool
IsAmbiguous implements the Type interface.
func (TPlaceholder) Size ¶
func (TPlaceholder) Size() (uintptr, bool)
Size implements the Type interface.
func (TPlaceholder) String ¶
func (t TPlaceholder) String() string
String implements the fmt.Stringer interface.
type TTuple ¶
type TTuple []Type
TTuple is the type of a DTuple.
func (TTuple) FamilyEqual ¶
FamilyEqual implements the Type interface.
func (TTuple) IsAmbiguous ¶
IsAmbiguous implements the Type interface.
type TableDef ¶
type TableDef interface { NodeFormatter // contains filtered or unexported methods }
TableDef represents a column, index or constraint definition within a CREATE TABLE statement.
type TableExpr ¶
type TableExpr interface { NodeFormatter // contains filtered or unexported methods }
TableExpr represents a table expression.
type TableName ¶
type TableName struct { DatabaseName Name TableName Name // contains filtered or unexported fields }
TableName corresponds to the name of a table in a FROM clause, INSERT or UPDATE statement (and possibly other places).
func ParseTableNameTraditional ¶
ParseTableNameTraditional parses a table name.
func (*TableName) NormalizeTableName ¶
NormalizeTableName implements the TableNameReference interface.
func (*TableName) NormalizeTablePattern ¶
func (t *TableName) NormalizeTablePattern() (TablePattern, error)
NormalizeTablePattern implements the TablePattern interface.
func (*TableName) NormalizedTableName ¶
NormalizedTableName normalize DatabaseName and TableName to lowercase and performs Unicode Normalization.
func (*TableName) QualifyWithDatabase ¶
QualifyWithDatabase adds an indirection for the database, if it's missing. It transforms: table -> database.table table@index -> database.table@index
type TableNameReference ¶
type TableNameReference interface { fmt.Stringer NodeFormatter NormalizeTableName() (*TableName, error) }
TableNameReference implements the editable cell of a TableExpr that refers to a single table.
type TableNameReferences ¶
type TableNameReferences []TableNameReference
TableNameReferences corresponds to a comma-delimited list of table name references.
type TableNameWithIndex ¶
type TableNameWithIndex struct { Table NormalizableTableName Index Name SearchTable bool }
TableNameWithIndex represents a "table@index", used in statements that specifically refer to an index.
type TableNameWithIndexList ¶
type TableNameWithIndexList []*TableNameWithIndex
TableNameWithIndexList is a list of indexes.
type TableNames ¶
type TableNames []TableName
TableNames represents a comma separated list (see the Format method) of table names.
func (TableNames) Format ¶
func (ts TableNames) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (TableNames) String ¶
func (ts TableNames) String() string
type TablePattern ¶
type TablePattern interface { fmt.Stringer NodeFormatter NormalizeTablePattern() (TablePattern, error) }
TablePattern is the common interface to UnresolvedName, TableName and AllTablesSelector.
type TablePatterns ¶
type TablePatterns []TablePattern
TablePatterns implement a comma-separated list of table patterns. Used by e.g. the GRANT statement.
type TargetList ¶
type TargetList struct { Databases NameList Tables TablePatterns }
TargetList represents a list of targets. Only one field may be non-nil.
type TimestampColType ¶
type TimestampColType struct { }
TimestampColType represents a TIMESTAMP type.
func (*TimestampColType) Format ¶
func (node *TimestampColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*TimestampColType) String ¶
func (node *TimestampColType) String() string
type TimestampTZColType ¶
type TimestampTZColType struct { }
TimestampTZColType represents a TIMESTAMP type.
func (*TimestampTZColType) Format ¶
func (node *TimestampTZColType) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*TimestampTZColType) String ¶
func (node *TimestampTZColType) String() string
type Truncate ¶
type Truncate struct { Tables TableNameReferences DropBehavior DropBehavior }
Truncate represents a TRUNCATE statement.
func (*Truncate) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Truncate) StatementType ¶
func (*Truncate) StatementType() StatementType
StatementType implements the Statement interface.
type Tuple ¶
type Tuple struct { Exprs Exprs // contains filtered or unexported fields }
Tuple represents a parenthesized list of expressions.
func (*Tuple) Eval ¶
func (t *Tuple) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (*Tuple) ResolvedType ¶
ResolvedType implements the TypedExpr interface.
type Type ¶
type Type interface { fmt.Stringer // Equal returns whether the receiver and the other type are the same. Prefer // == for determining equality with a TypeXxx constant except TypeTuple and // TypePlaceholder. Equal(other Type) bool // FamilyEqual returns whether the receiver and the other type have the same // constructor. FamilyEqual(other Type) bool // Size returns a lower bound on the total size of a Datum whose type is the // receiver in bytes, including memory that is pointed at (even if shared // between Datum instances) but excluding allocation overhead. // // The second argument indicates whether data of this type have different // sizes. // // It holds for every Datum d that d.Size() >= d.ResolvedType().Size(). Size() (uintptr, bool) // IsAmbiguous returns whether the type is ambiguous or fully defined. This // is important for parameterized types to determine whether they are fully // concrete type specification or not. IsAmbiguous() bool }
Type represents a SQL type.
var ( // TypeNull is the type of a DNull. Can be compared with ==. TypeNull Type = tNull{} // TypeBool is the type of a DBool. Can be compared with ==. TypeBool Type = tBool{} // TypeInt is the type of a DInt. Can be compared with ==. TypeInt Type = tInt{} // TypeFloat is the type of a DFloat. Can be compared with ==. TypeFloat Type = tFloat{} // TypeDecimal is the type of a DDecimal. Can be compared with ==. TypeDecimal Type = tDecimal{} // TypeString is the type of a DString. Can be compared with ==. TypeString Type = tString{} // TypeCollatedString is the type family of a DString. CANNOT be compared with // ==. TypeCollatedString Type = TCollatedString{} // TypeBytes is the type of a DBytes. Can be compared with ==. TypeBytes Type = tBytes{} // TypeDate is the type of a DDate. Can be compared with ==. TypeDate Type = tDate{} // TypeTimestamp is the type of a DTimestamp. Can be compared with ==. TypeTimestamp Type = tTimestamp{} // TypeTimestampTZ is the type of a DTimestampTZ. Can be compared with ==. TypeTimestampTZ Type = tTimestampTZ{} // TypeInterval is the type of a DInterval. Can be compared with ==. TypeInterval Type = tInterval{} // TypeTuple is the type family of a DTuple. CANNOT be compared with ==. TypeTuple Type = TTuple(nil) // TypePlaceholder is the type family of a placeholder. CANNOT be compared // with ==. TypePlaceholder Type = TPlaceholder{} // TypeArray is the type family of a DArray. Can be compared with ==. TypeArray Type = tArray{TypeString} // TypeAny can be any type. Can be compared with ==. TypeAny Type = tAny{} )
type TypedExpr ¶
type TypedExpr interface { Expr // Eval evaluates an SQL expression. Expression evaluation is a // mostly straightforward walk over the parse tree. The only // significant complexity is the handling of types and implicit // conversions. See binOps and cmpOps for more details. Note that // expression evaluation returns an error if certain node types are // encountered: Placeholder, VarName (and related UnqualifiedStar, // UnresolvedName and AllColumnsSelector) or Subquery. These nodes // should be replaced prior to expression evaluation by an // appropriate WalkExpr. For example, Placeholder should be replace // by the argument passed from the client. Eval(*EvalContext) (Datum, error) // ResolvedType provides the type of the TypedExpr, which is the type of Datum // that the TypedExpr will return when evaluated. ResolvedType() Type }
TypedExpr represents a well-typed expression.
func ReType ¶
ReType ensures that the given numeric expression evaluates to the requested type, inserting a cast if necessary.
func TypeCheck ¶
func TypeCheck(expr Expr, ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck performs type checking on the provided expression tree, returning the new typed expression tree, which additionally permits evaluation and type introspection globally and on each sub-tree.
While doing so, it will fold numeric constants and bind placeholder names to their inferred types in the provided context. The optional desired parameter can be used to hint the desired type for the root of the resulting typed expression tree.
func TypeCheckAndRequire ¶
TypeCheckAndRequire performs type checking on the provided expression tree in an identical manner to TypeCheck. It then asserts that the resulting TypedExpr has the provided return type, returning both the typed expression and an error if it does not.
func TypeConstants ¶
TypeConstants type checks all Constant literal expressions, resolving them as the Datum representations of their values. Before doing so, it first folds all numeric constants.
This means that Constants will become TypedExprs so that they can be used in contexts which expect a TypedExpr tree (such as Normalization). As such, the function is primarily intended for use while testing expressions where full type checking is not desired.
TODO(nvanbenschoten) Can this visitor be preallocated (like normalizeVisitor)?
type TypedExprs ¶
type TypedExprs []TypedExpr
TypedExprs represents a list of well-typed value expressions. It's not a valid expression because it's not parenthesized.
func (TypedExprs) String ¶
func (node TypedExprs) String() string
type UnaryExpr ¶
type UnaryExpr struct { Operator UnaryOperator Expr Expr // contains filtered or unexported fields }
UnaryExpr represents a unary value expression.
func (*UnaryExpr) Eval ¶
func (expr *UnaryExpr) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (UnaryExpr) ResolvedType ¶
func (ta UnaryExpr) ResolvedType() Type
func (*UnaryExpr) TypeCheck ¶
func (expr *UnaryExpr) TypeCheck(ctx *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (*UnaryExpr) TypedInnerExpr ¶
TypedInnerExpr returns the UnaryExpr's inner expression as a TypedExpr.
type UnaryOperator ¶
type UnaryOperator int
UnaryOperator represents a unary operator.
const ( UnaryPlus UnaryOperator = iota UnaryMinus UnaryComplement )
UnaryExpr.Operator
func (UnaryOperator) String ¶
func (i UnaryOperator) String() string
type UnionClause ¶
UnionClause represents a UNION statement.
func (*UnionClause) Format ¶
func (node *UnionClause) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (*UnionClause) StatementTag ¶
func (*UnionClause) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (*UnionClause) StatementType ¶
func (*UnionClause) StatementType() StatementType
StatementType implements the Statement interface.
func (*UnionClause) String ¶
func (n *UnionClause) String() string
type UniqueConstraint ¶
type UniqueConstraint struct{}
UniqueConstraint represents UNIQUE on a column.
type UniqueConstraintTableDef ¶
type UniqueConstraintTableDef struct { IndexTableDef PrimaryKey bool }
UniqueConstraintTableDef represents a unique constraint within a CREATE TABLE statement.
type UnqualifiedStar ¶
type UnqualifiedStar struct{}
UnqualifiedStar corresponds to a standalone '*' in an expression or a '*' as name part of an UnresolvedName.
func (UnqualifiedStar) Eval ¶
func (expr UnqualifiedStar) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (UnqualifiedStar) Format ¶
func (UnqualifiedStar) Format(buf *bytes.Buffer, _ FmtFlags)
Format implements the NodeFormatter interface.
func (UnqualifiedStar) NormalizeVarName ¶
func (u UnqualifiedStar) NormalizeVarName() (VarName, error)
NormalizeVarName is a no-op for UnqualifiedStar (already normalized)
func (UnqualifiedStar) ResolvedType ¶
func (UnqualifiedStar) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (UnqualifiedStar) String ¶
func (u UnqualifiedStar) String() string
func (UnqualifiedStar) TypeCheck ¶
func (expr UnqualifiedStar) TypeCheck(_ *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (UnqualifiedStar) Variable ¶
func (UnqualifiedStar) Variable()
Variable implements the VariableExpr interface.
func (UnqualifiedStar) Walk ¶
func (expr UnqualifiedStar) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type UnresolvedName ¶
type UnresolvedName NameParts
UnresolvedName holds the initial syntax of a name as determined during parsing.
func (UnresolvedName) Eval ¶
func (expr UnresolvedName) Eval(ctx *EvalContext) (Datum, error)
Eval implements the TypedExpr interface.
func (UnresolvedName) Format ¶
func (u UnresolvedName) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (UnresolvedName) NormalizeTableName ¶
func (n UnresolvedName) NormalizeTableName() (*TableName, error)
NormalizeTableName implements the TableNameReference interface.
func (UnresolvedName) NormalizeTablePattern ¶
func (n UnresolvedName) NormalizeTablePattern() (TablePattern, error)
NormalizeTablePattern resolves an UnresolvedName to either a TableName or AllTablesSelector.
func (UnresolvedName) NormalizeUnqualifiedColumnItem ¶
func (n UnresolvedName) NormalizeUnqualifiedColumnItem() (*ColumnItem, error)
NormalizeUnqualifiedColumnItem normalizes a UnresolvedName for all the forms it can have inside a context that requires an unqualified column item (e.g. UPDATE LHS, INSERT, etc.).
func (UnresolvedName) NormalizeVarName ¶
func (n UnresolvedName) NormalizeVarName() (VarName, error)
NormalizeVarName normalizes a UnresolvedName for all the forms it can have inside an expression context.
func (UnresolvedName) ResolveFunction ¶
func (n UnresolvedName) ResolveFunction(searchPath []string) (*FunctionDefinition, error)
ResolveFunction transforms an UnresolvedName to a FunctionDefinition.
func (UnresolvedName) ResolvedType ¶
func (UnresolvedName) ResolvedType() Type
ResolvedType implements the TypedExpr interface.
func (UnresolvedName) String ¶
func (u UnresolvedName) String() string
func (UnresolvedName) TypeCheck ¶
func (expr UnresolvedName) TypeCheck(s *SemaContext, desired Type) (TypedExpr, error)
TypeCheck implements the Expr interface.
func (UnresolvedName) Variable ¶
func (UnresolvedName) Variable()
Variable implements the VariableExpr interface. Although, the UnresolvedName ought to be replaced to an IndexedVar before the points the VariableExpr interface is used.
func (UnresolvedName) Walk ¶
func (expr UnresolvedName) Walk(_ Visitor) Expr
Walk implements the Expr interface.
type UnresolvedNames ¶
type UnresolvedNames []UnresolvedName
UnresolvedNames corresponds to a comma-separate list of unresolved names. Note: this should be treated as immutable when embedded in an Expr context, otherwise the Walk code must be updated to duplicate the array an Expr node is duplicated.
type Update ¶
type Update struct { Table TableExpr Exprs UpdateExprs Where *Where Returning ReturningExprs }
Update represents an UPDATE statement.
func (*Update) StatementTag ¶
StatementTag returns a short string identifying the type of statement.
func (*Update) StatementType ¶
func (n *Update) StatementType() StatementType
StatementType implements the Statement interface.
type UpdateExpr ¶
type UpdateExpr struct { Tuple bool Names UnresolvedNames Expr Expr }
UpdateExpr represents an update expression.
type UpdateExprs ¶
type UpdateExprs []*UpdateExpr
UpdateExprs represents a list of update expressions.
type UserPriority ¶
type UserPriority int
UserPriority holds the user priority for a transaction.
const ( UnspecifiedUserPriority UserPriority = iota Low Normal High )
UserPriority values
func (UserPriority) String ¶
func (up UserPriority) String() string
type UsingJoinCond ¶
type UsingJoinCond struct {
Cols NameList
}
UsingJoinCond represents a USING join condition.
type ValidationBehavior ¶
type ValidationBehavior int
ValidationBehavior specifies whether or not a constraint is validated.
const ( // ValidationDefault is the default validation behavior (immediate). ValidationDefault ValidationBehavior = iota // ValidationSkip skips validation of any existing data. ValidationSkip )
type ValuesClause ¶
type ValuesClause struct {
Tuples []*Tuple
}
ValuesClause represents a VALUES clause.
func (*ValuesClause) Format ¶
func (node *ValuesClause) Format(buf *bytes.Buffer, f FmtFlags)
Format implements the NodeFormatter interface.
func (ValuesClause) StatementTag ¶
func (ValuesClause) StatementTag() string
StatementTag returns a short string identifying the type of statement.
func (ValuesClause) StatementType ¶
func (ValuesClause) StatementType() StatementType
StatementType implements the Statement interface.
func (*ValuesClause) String ¶
func (n *ValuesClause) String() string
func (*ValuesClause) WalkStmt ¶
func (stmt *ValuesClause) WalkStmt(v Visitor) Statement
WalkStmt is part of the WalkableStmt interface.
type VarName ¶
VarName is the common interface to UnresolvedName, ColumnItem and AllColumnsSelector for use in expression contexts.
type VariableExpr ¶
type VariableExpr interface { Expr Variable() }
VariableExpr is an Expr that may change per row. It is used to signal the evaluation/simplification machinery that the underlying Expr is not constant.
type VariadicType ¶
type VariadicType struct {
Typ Type
}
VariadicType is a typeList implementation which accepts any number of arguments and matches when each argument is either NULL or of the type typ.
func (VariadicType) Length ¶
func (v VariadicType) Length() int
Length implements the typeList interface.
func (VariadicType) String ¶
func (v VariadicType) String() string
func (VariadicType) Types ¶
func (v VariadicType) Types() []Type
Types implements the typeList interface.
type Visitor ¶
type Visitor interface { // VisitPre is called for each node before recursing into that subtree. Upon return, if recurse // is false, the visit will not recurse into the subtree (and VisitPost will not be called for // this node). // // The returned Expr replaces the visited expression and can be used for rewriting expressions. // The function should NOT modify nodes in-place; it should make copies of nodes. The Walk // infrastructure will automatically make copies of parents as needed. VisitPre(expr Expr) (recurse bool, newExpr Expr) // VisitPost is called for each node after recursing into the subtree. The returned Expr // replaces the visited expression and can be used for rewriting expressions. // // The returned Expr replaces the visited expression and can be used for rewriting expressions. // The function should NOT modify nodes in-place; it should make and return copies of nodes. The // Walk infrastructure will automatically make copies of parents as needed. VisitPost(expr Expr) (newNode Expr) }
Visitor defines methods that are called for nodes during an expression or statement walk.
type WalkableStmt ¶
WalkableStmt is implemented by statements that can appear inside an expression (selects) or we want to start a walk from (using WalkStmt).
type WindowFrame ¶
type WindowFrame struct { // constant for all calls to WindowFunc.Add Rows []IndexedRow ArgIdxStart int // the index which arguments to the window function begin ArgCount int // the number of window function arguments // changes for each row (each call to WindowFunc.Add) RowIdx int // the current row index // changes for each peer group FirstPeerIdx int // the first index in the current peer group PeerRowCount int // the number of rows in the current peer group }
WindowFrame is a view into a subset of data over which calculations are made.
type WindowFunc ¶
type WindowFunc interface { // Compute computes the window function for the provided window frame, given the // current state of WindowFunc. The method should be called sequentially for every // row in a partition in turn with the desired ordering of the WindowFunc. This is // because there is an implicit carried dependency between each row and all those // that have come before it (like in an AggregateFunc). As such, this approach does // not present any exploitable associativity/commutativity for optimization. Compute(WindowFrame) (Datum, error) }
WindowFunc performs a computation on each row using data from a provided WindowFrame.
Source Files ¶
- aggregate_builtins.go
- alter_table.go
- builtins.go
- col_types.go
- constant.go
- copy.go
- create.go
- datum.go
- delete.go
- drop.go
- encode.go
- eval.go
- explain.go
- expr.go
- format.go
- function_name.go
- grant.go
- indexed_vars.go
- insert.go
- interval.go
- keywords.go
- name_part.go
- normalize.go
- overload.go
- parse.go
- placeholders.go
- prepare.go
- regexp_cache.go
- rename.go
- reserved_keywords.go
- returning.go
- revoke.go
- scan.go
- select.go
- set.go
- show.go
- split.go
- sql.y
- star_datum.go
- stmt.go
- syntax_string.go
- table_name.go
- table_pattern.go
- truncate.go
- txn.go
- type.go
- type_check.go
- union.go
- update.go
- values.go
- var_name.go
- walk.go
- window_builtins.go