abstract

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuzzAnalyse

func FuzzAnalyse(data []byte) int

FuzzAnalyse implements the fuzzer

Types

type Join

type Join struct {
	LHS, RHS Operator
	Exp      sqlparser.Expr
}

Join represents an join. If we have a predicate, this is an inner join. If no predicate exists, it is a cross join

func (*Join) PushPredicate

func (j *Join) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) error

PushPredicate implements the Operator interface

func (*Join) TableID

func (j *Join) TableID() semantics.TableSet

TableID implements the Operator interface

type LeftJoin

type LeftJoin struct {
	Left, Right Operator
	Predicate   sqlparser.Expr
}

LeftJoin represents an outerjoin.

func (*LeftJoin) PushPredicate

func (oj *LeftJoin) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) error

PushPredicate implements the Operator interface

func (*LeftJoin) TableID

func (oj *LeftJoin) TableID() semantics.TableSet

TableID implements the Operator interface

type Operator

type Operator interface {
	// TableID returns a TableSet of the tables contained within
	TableID() semantics.TableSet

	// PushPredicate pushes a predicate to the closest possible operator
	PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) error
}

Operator forms the tree of operators, representing the declarative query provided. An operator can be:

  • QueryGraph - which represents a group of tables and predicates that can be evaluated in any order while still preserving the results
  • LeftJoin - A left join. These can't be evaluated in any order, so we keep them separate
  • Join - A join represents inner join.

func CreateOperatorFromSelect

func CreateOperatorFromSelect(sel *sqlparser.Select, semTable *semantics.SemTable) (Operator, error)

CreateOperatorFromSelect creates an operator tree that represents the input SELECT query

type QueryGraph

type QueryGraph struct {
	// the Tables, including predicates that only depend on this particular table
	Tables []*QueryTable

	// NoDeps contains the predicates that can be evaluated anywhere.
	NoDeps sqlparser.Expr
	// contains filtered or unexported fields
}

QueryGraph represents the FROM and WHERE parts of a query.

It is an intermediate representation of the query that makes it easier for the planner
to find all possible join combinations. Instead of storing the query information in a form that is close
to the syntax (AST), we extract the interesting parts into a graph form with the nodes being tables in the FROM
clause and the edges between them being predicates. We keep predicates in a hash map keyed by the dependencies of
the predicate. This makes it very fast to look up connections between tables in the query.

func (*QueryGraph) GetPredicates

func (qg *QueryGraph) GetPredicates(lhs, rhs semantics.TableSet) []sqlparser.Expr

GetPredicates returns the predicates that are applicable for the two given TableSets

func (*QueryGraph) PushPredicate

func (qg *QueryGraph) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) error

PushPredicate implements the Operator interface

func (*QueryGraph) TableID

func (qg *QueryGraph) TableID() semantics.TableSet

TableID implements the Operator interface

type QueryTable

type QueryTable struct {
	TableID    semantics.TableSet
	Alias      *sqlparser.AliasedTableExpr
	Table      sqlparser.TableName
	Predicates []sqlparser.Expr
}

QueryTable is a single FROM table, including all predicates particular to this table

Jump to

Keyboard shortcuts

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