Documentation ¶
Index ¶
- Constants
- Variables
- func DeepCopyNode(node sql.Node) (sql.Node, error)
- func ExpressionToColumnDefaultValue(inputExpr sql.Expression, isLiteral, isParenthesized bool) *sql.ColumnDefaultValue
- func MustStringToColumnDefaultValue(ctx *sql.Context, exprStr string, outType sql.Type, nullable bool) *sql.ColumnDefaultValue
- func Parse(ctx *sql.Context, cat sql.Catalog, query string) (ret sql.Node, err error)
- func ParseColumnTypeString(columnType string) (sql.Type, error)
- func ParseOne(ctx *sql.Context, cat sql.Catalog, query string) (sql.Node, string, string, error)
- func ParseOnly(ctx *sql.Context, query string, multi bool) (ast.Statement, string, string, error)
- func ParseWithOptions(ctx *sql.Context, cat sql.Catalog, query string, options ast.ParserOptions) (ret sql.Node, err error)
- func RemoveSpaceAndDelimiter(query string, d rune) string
- func StringToColumnDefaultValue(ctx *sql.Context, exprStr string) (*sql.ColumnDefaultValue, error)
- type BindvarContext
- type Builder
- func (b *Builder) BindCtx() *BindvarContext
- func (b *Builder) BindOnly(stmt ast.Statement, s string) (ret sql.Node, err error)
- func (b *Builder) ConvertVal(v *ast.SQLVal) sql.Expression
- func (b *Builder) Initialize(ctx *sql.Context, cat sql.Catalog, opts ast.ParserOptions)
- func (b *Builder) NewFrame(inScope *scope, f *ast.Frame) sql.WindowFrame
- func (b *Builder) Parse(query string, multi bool) (ret sql.Node, parsed, remainder string, err error)
- func (b *Builder) ParseOne(query string) (ret sql.Node, err error)
- func (b *Builder) ProcCtx() *ProcContext
- func (b *Builder) Reset()
- func (b *Builder) SetBindings(bindings map[string]*querypb.BindVariable)
- func (b *Builder) SetDebug(val bool)
- func (b *Builder) SetParserOptions(opts ast.ParserOptions)
- func (b *Builder) TriggerCtx() *TriggerContext
- func (b *Builder) ViewCtx() *ViewContext
- type ProcContext
- type TriggerContext
- type ViewContext
Constants ¶
const ExtendedTypeTag = "extended_"
ExtendedTypeTag is primarily used by ParseColumnTypeString when parsing strings representing extended types
const OnDupValuesPrefix = "__new_ins"
Variables ¶
var ( ErrPrimaryKeyOnNullField = errors.NewKind("All parts of PRIMARY KEY must be NOT NULL") // ErrUnionSchemasDifferentLength is returned when the two sides of a // UNION do not have the same number of columns in their schemas. ErrUnionSchemasDifferentLength = errors.NewKind( "cannot union two queries whose schemas are different lengths; left has %d column(s) right has %d column(s).", ) ErrQualifiedOrderBy = errors.NewKind("Table '%s' from one of the SELECTs cannot be used in global ORDER clause") ErrOrderByBinding = errors.NewKind("bindings in sort clauses not supported yet") ErrFailedToParseStats = errors.NewKind("failed to parse data: %s\n%s") )
var BinderFactory = &sync.Pool{New: func() interface{} { return &Builder{f: &factory{}} }}
var ErrMaxAnalysisIters = errors.NewKind("exceeded max analysis iterations (%d)")
ErrMaxAnalysisIters is thrown when the analysis iterations are exceeded
Functions ¶
func DeepCopyNode ¶
DeepCopyNode copies a sql.Node.
func ExpressionToColumnDefaultValue ¶
func ExpressionToColumnDefaultValue(inputExpr sql.Expression, isLiteral, isParenthesized bool) *sql.ColumnDefaultValue
ExpressionToColumnDefaultValue takes in an Expression and returns the equivalent ColumnDefaultValue if the expression is valid for a default value. If the expression represents a literal (and not an expression that returns a literal, so "5" rather than "(5)"), then the parameter "isLiteral" should be true.
func MustStringToColumnDefaultValue ¶
func MustStringToColumnDefaultValue(ctx *sql.Context, exprStr string, outType sql.Type, nullable bool) *sql.ColumnDefaultValue
MustStringToColumnDefaultValue is used for creating default values on tables that do not go through the analyzer. Does not handle function nor column references.
func Parse ¶
Parse parses the given SQL |query| using the default parsing settings and returns the corresponding node.
func ParseWithOptions ¶
func RemoveSpaceAndDelimiter ¶
RemoveSpaceAndDelimiter removes space characters and given delimiter characters from the given query.
func StringToColumnDefaultValue ¶
StringToColumnDefaultValue takes in a string representing a default value and returns the equivalent Expression.
Types ¶
type BindvarContext ¶
type BindvarContext struct { Bindings map[string]*querypb.BindVariable // contains filtered or unexported fields }
BindvarContext holds bind variable replacement literals.
func (*BindvarContext) GetSubstitute ¶
func (bv *BindvarContext) GetSubstitute(s string) (*querypb.BindVariable, bool)
func (*BindvarContext) UnusedBindings ¶
func (bv *BindvarContext) UnusedBindings() []string
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) BindCtx ¶
func (b *Builder) BindCtx() *BindvarContext
func (*Builder) ConvertVal ¶
func (b *Builder) ConvertVal(v *ast.SQLVal) sql.Expression
func (*Builder) Initialize ¶
func (*Builder) ProcCtx ¶
func (b *Builder) ProcCtx() *ProcContext
func (*Builder) SetBindings ¶
func (b *Builder) SetBindings(bindings map[string]*querypb.BindVariable)
func (*Builder) SetParserOptions ¶
func (b *Builder) SetParserOptions(opts ast.ParserOptions)
func (*Builder) TriggerCtx ¶
func (b *Builder) TriggerCtx() *TriggerContext
func (*Builder) ViewCtx ¶
func (b *Builder) ViewCtx() *ViewContext
type ProcContext ¶
type ProcContext struct { AsOf interface{} DbName string }
ProcContext allows nested CALLs to use the same database for resolving procedure definitions without changing the underlying database roots.
type TriggerContext ¶
type ViewContext ¶
type ViewContext struct { AsOf interface{} DbName string }
ViewContext overwrites database root source of nested calls.
Source Files ¶
- aggregates.go
- analyze.go
- binlog_replication.go
- builder.go
- create_ddl.go
- cte.go
- ddl.go
- dml.go
- dml_validate.go
- doc.go
- errors.go
- explain.go
- factory.go
- from.go
- load.go
- orderby.go
- parse.go
- parse_column_default.go
- priv.go
- proc.go
- process.go
- project.go
- scalar.go
- scope.go
- select.go
- set.go
- set_op.go
- show.go
- spatial.go
- subquery.go
- transactions.go
- window_frame_factory.go
- window_frame_factory.og.go