planbuilder

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 33 Imported by: 10

Documentation

Index

Constants

View Source
const ExtendedTypeTag = "extended_"

ExtendedTypeTag is primarily used by ParseColumnTypeString when parsing strings representing extended types

View Source
const OnDupValuesPrefix = "__new_ins"

Variables

View Source
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")
)
View Source
var BinderFactory = &sync.Pool{New: func() interface{} {
	return &Builder{f: &factory{}}
}}
View Source
var ErrMaxAnalysisIters = errors.NewKind("exceeded max analysis iterations (%d)")

ErrMaxAnalysisIters is thrown when the analysis iterations are exceeded

Functions

func DeepCopyNode

func DeepCopyNode(node sql.Node) (sql.Node, error)

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 added in v0.17.0

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

func Parse(ctx *sql.Context, cat sql.Catalog, query string) (sql.Node, *sql.QueryFlags, error)

Parse parses the given SQL |query| using the default parsing settings and returns the corresponding node.

func ParseColumnTypeString added in v0.17.0

func ParseColumnTypeString(columnType string) (sql.Type, error)

func ParseWithOptions added in v0.17.0

func ParseWithOptions(ctx *sql.Context, cat sql.Catalog, query string, options ast.ParserOptions) (sql.Node, *sql.QueryFlags, error)

func StringToColumnDefaultValue added in v0.17.0

func StringToColumnDefaultValue(ctx *sql.Context, exprStr string) (*sql.ColumnDefaultValue, error)

StringToColumnDefaultValue takes in a string representing a default value and returns the equivalent Expression.

Types

type BindvarContext added in v0.18.0

type BindvarContext struct {
	Bindings map[string]sql.Expression
	// contains filtered or unexported fields
}

BindvarContext holds bind variable replacement literals.

func (*BindvarContext) GetSubstitute added in v0.18.0

func (bv *BindvarContext) GetSubstitute(s string) (sql.Expression, bool)

func (*BindvarContext) UnusedBindings added in v0.18.0

func (bv *BindvarContext) UnusedBindings() []string

type Builder added in v0.17.0

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

func New added in v0.17.0

func New(ctx *sql.Context, cat sql.Catalog, es sql.EventScheduler, p sql.Parser) *Builder

New takes ctx, catalog, event scheduler, and parser. If the parser is nil, then default parser is mysql parser.

func (*Builder) BindCtx added in v0.18.0

func (b *Builder) BindCtx() *BindvarContext

func (*Builder) BindOnly added in v0.17.0

func (b *Builder) BindOnly(stmt ast.Statement, s string, queryFlags *sql.QueryFlags) (_ sql.Node, _ *sql.QueryFlags, err error)

func (*Builder) BuildColumnDefaultValueWithTable added in v0.19.0

func (b *Builder) BuildColumnDefaultValueWithTable(defExpr ast.Expr, tableExpr ast.TableExpr, typ sql.Type, nullable bool) *sql.ColumnDefaultValue

func (*Builder) BuildScalarWithTable added in v0.19.0

func (b *Builder) BuildScalarWithTable(expr ast.Expr, tableExpr ast.TableExpr) sql.Expression

func (*Builder) ConvertVal added in v0.17.0

func (b *Builder) ConvertVal(v *ast.SQLVal) sql.Expression

func (*Builder) DisableAuth added in v0.19.0

func (b *Builder) DisableAuth()

DisableAuth disables all authorization checks.

func (*Builder) EnableAuth added in v0.19.0

func (b *Builder) EnableAuth()

EnableAuth enables all authorization checks. Auth is enabled by default, so this only needs to be called when it was previously disabled using DisableAuth.

func (*Builder) NewFrame added in v0.17.0

func (b *Builder) NewFrame(inScope *scope, f *ast.Frame) sql.WindowFrame

func (*Builder) Parse added in v0.17.0

func (b *Builder) Parse(query string, qFlags *sql.QueryFlags, multi bool) (ret sql.Node, parsed, remainder string, qProps *sql.QueryFlags, err error)

func (*Builder) ProcCtx added in v0.17.0

func (b *Builder) ProcCtx() *ProcContext

func (*Builder) Reset added in v0.18.0

func (b *Builder) Reset()

func (*Builder) SetBindings added in v0.18.0

func (b *Builder) SetBindings(bindings map[string]ast.Expr)

func (*Builder) SetBindingsWithExpr added in v0.19.0

func (b *Builder) SetBindingsWithExpr(bindings map[string]sql.Expression)

func (*Builder) SetDebug added in v0.18.0

func (b *Builder) SetDebug(val bool)

func (*Builder) SetParserOptions added in v0.17.0

func (b *Builder) SetParserOptions(opts ast.ParserOptions)

func (*Builder) TriggerCtx added in v0.17.0

func (b *Builder) TriggerCtx() *TriggerContext

func (*Builder) ViewCtx added in v0.17.0

func (b *Builder) ViewCtx() *ViewContext

type ProcContext added in v0.17.0

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 added in v0.17.0

type TriggerContext struct {
	Active           bool
	Call             bool
	UnresolvedTables []string
	ResolveErr       error
}

type ViewContext added in v0.17.0

type ViewContext struct {
	AsOf   interface{}
	DbName string
}

ViewContext overwrites database root source of nested calls.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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