parse

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

package parse contains logic for parsing SQL, DDL, and Actions, and SQL.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSyntax                    = errors.New("syntax error")
	ErrType                      = errors.New("type error")
	ErrTableDefinition           = errors.New("table definition error")
	ErrUnknownColumn             = errors.New("unknown column reference")
	ErrDuplicateParameterName    = errors.New("duplicate parameter name")
	ErrDuplicateResultColumnName = errors.New("duplicate result column name")
	ErrIdentifier                = errors.New("identifier error")
	ErrCollation                 = errors.New("collation error")
	ErrNoPrimaryKey              = errors.New("missing primary key")
	ErrRedeclaredPrimaryKey      = errors.New("redeclare primary key")
	ErrRedeclaredConstraint      = errors.New("redeclared constraint")
	ErrGrantOrRevoke             = errors.New("grant or revoke error")
)

Functions

func RecursivelyVisitPositions

func RecursivelyVisitPositions(v any, fn func(GetPositioner))

RecursivelyVisitPositions traverses a structure recursively, visiting all position struct types. It is used in both parsing tools, as well as in tests. WARNING: This function should NEVER be used in consensus, since it is non-deterministic.

Types

type ActionReturn

type ActionReturn struct {
	Position
	// IsTable is true if the return type is a table.
	IsTable bool
	// Fields are the fields of the return type.
	Fields []*engine.NamedType
}

ActionReturn is the return struct of the action.

type ActionStmt

type ActionStmt interface {
	Node
	// contains filtered or unexported methods
}

ActionStmt is a statement in a actiob. it is the top-level interface for all action statements.

type ActionStmtAssign

type ActionStmtAssign struct {

	// Variable is the variable that is being assigned.
	Variable Assignable
	// Type is the type of the variable.
	// It can be nil if the variable is not being assigned,
	// or if the type should be inferred.
	Type *types.DataType
	// Value is the value that is being assigned.
	Value Expression
	// contains filtered or unexported fields
}

ActionStmtAssign is a variable assignment in an action. It should only be called on variables that have already been declared.

func (*ActionStmtAssign) Accept

func (p *ActionStmtAssign) Accept(v Visitor) any

type ActionStmtCall

type ActionStmtCall struct {

	// Receivers are the variables being assigned. If nil, then the
	// receiver can be ignored.
	Receivers []*ExpressionVariable
	Call      *ExpressionFunctionCall
	// contains filtered or unexported fields
}

ActionStmtCall is a call to another action or built-in function.

func (*ActionStmtCall) Accept

func (p *ActionStmtCall) Accept(v Visitor) any

type ActionStmtDeclaration

type ActionStmtDeclaration struct {

	// Variable is the variable that is being declared.
	Variable *ExpressionVariable
	Type     *types.DataType
	// contains filtered or unexported fields
}

ActionStmtDeclaration is a variable declaration in an action.

func (*ActionStmtDeclaration) Accept

func (p *ActionStmtDeclaration) Accept(v Visitor) any

type ActionStmtForLoop

type ActionStmtForLoop struct {

	// Receiver is the variable that is assigned on each iteration.
	Receiver *ExpressionVariable
	// LoopTerm is what the loop is looping through.
	LoopTerm LoopTerm
	// Body is the body of the loop.
	Body []ActionStmt
	// contains filtered or unexported fields
}

func (*ActionStmtForLoop) Accept

func (p *ActionStmtForLoop) Accept(v Visitor) any

type ActionStmtIf

type ActionStmtIf struct {

	// IfThens are the if statements.
	// They are evaluated in order, as
	// IF ... THEN ... ELSEIF ... THEN ...
	IfThens []*IfThen
	// Else is the else statement.
	// It is evaluated if no other if statement
	// is true.
	Else []ActionStmt
	// contains filtered or unexported fields
}

func (*ActionStmtIf) Accept

func (p *ActionStmtIf) Accept(v Visitor) any

type ActionStmtLoopControl

type ActionStmtLoopControl struct {
	Type LoopControlType
	// contains filtered or unexported fields
}

func (*ActionStmtLoopControl) Accept

func (p *ActionStmtLoopControl) Accept(v Visitor) any

type ActionStmtReturn

type ActionStmtReturn struct {

	// Values are the values to return.
	// Either values is set or SQL is set, but not both.
	Values []Expression
	// SQL is the SQL statement to return.
	// Either values is set or SQL is set, but not both.
	SQL *SQLStatement
	// contains filtered or unexported fields
}

func (*ActionStmtReturn) Accept

func (p *ActionStmtReturn) Accept(v Visitor) any

type ActionStmtReturnNext

type ActionStmtReturnNext struct {

	// Values are the values to return.
	Values []Expression
	// contains filtered or unexported fields
}

func (*ActionStmtReturnNext) Accept

func (p *ActionStmtReturnNext) Accept(v Visitor) any

type ActionStmtSQL

type ActionStmtSQL struct {
	SQL *SQLStatement
	// contains filtered or unexported fields
}

func (*ActionStmtSQL) Accept

func (p *ActionStmtSQL) Accept(v Visitor) any

type ActionVisitor

type ActionVisitor interface {
	SQLVisitor
	VisitActionStmtDeclaration(*ActionStmtDeclaration) any
	VisitActionStmtAssignment(*ActionStmtAssign) any
	VisitActionStmtCall(*ActionStmtCall) any
	VisitActionStmtForLoop(*ActionStmtForLoop) any
	VisitLoopTermRange(*LoopTermRange) any
	VisitLoopTermSQL(*LoopTermSQL) any
	VisitLoopTermExpression(*LoopTermExpression) any
	VisitActionStmtIf(*ActionStmtIf) any
	VisitIfThen(*IfThen) any
	VisitActionStmtSQL(*ActionStmtSQL) any
	VisitActionStmtLoopControl(*ActionStmtLoopControl) any
	VisitActionStmtReturn(*ActionStmtReturn) any
	VisitActionStmtReturnNext(*ActionStmtReturnNext) any
}

ActionVisitor includes visit methods only needed to analyze actions. It does not need visit methods for structs that are for the schema or actions

type AddColumn

type AddColumn struct {
	Position
	Name        string
	Type        *types.DataType
	IfNotExists bool
}

func (*AddColumn) Accept

func (a *AddColumn) Accept(v Visitor) any

type AddTableConstraint

type AddTableConstraint struct {
	Position
	Constraint *OutOfLineConstraint
}

AddTableConstraint is a constraint that is being added to a table. It is used to specify multi-column constraints.

func (*AddTableConstraint) Accept

func (a *AddTableConstraint) Accept(v Visitor) any

type AlterColumnDrop

type AlterColumnDrop struct {
	Position
	Column string
	Type   SingleColumnConstraintType
}

AlterColumnDrop is "ALTER COLUMN ... DROP ..." statement.

func (*AlterColumnDrop) Accept

func (a *AlterColumnDrop) Accept(v Visitor) any

type AlterColumnSet

type AlterColumnSet struct {
	Position
	// Column is the column that is being altered.
	Column string
	// Type is the type of constraint that is being set.
	Type SingleColumnConstraintType
	// Value is the value of the constraint.
	// It is only set if the type is DEFAULT.
	Value Expression
}

AlterColumnSet is "ALTER COLUMN ... SET ..." statement.

func (*AlterColumnSet) Accept

func (a *AlterColumnSet) Accept(v Visitor) any

type AlterTableAction

type AlterTableAction interface {
	Node
	// contains filtered or unexported methods
}

type AlterTableStatement

type AlterTableStatement struct {
	Position
	Namespacing
	Table   string
	Actions []AlterTableAction
}

AlterTableStatement is a ALTER TABLE statement.

func (*AlterTableStatement) Accept

func (a *AlterTableStatement) Accept(v Visitor) any

type ArithmeticOperator

type ArithmeticOperator string
const (
	ArithmeticOperatorAdd      ArithmeticOperator = "+"
	ArithmeticOperatorSubtract ArithmeticOperator = "-"
	ArithmeticOperatorMultiply ArithmeticOperator = "*"
	ArithmeticOperatorDivide   ArithmeticOperator = "/"
	ArithmeticOperatorModulo   ArithmeticOperator = "%"
	ArithmeticOperatorExponent ArithmeticOperator = "^"
	ArithmeticOperatorConcat   ArithmeticOperator = "||"
)

type Assignable

type Assignable interface {
	Expression
	// contains filtered or unexported methods
}

Assignable is an interface for all expressions that can be assigned to.

type CheckConstraint

type CheckConstraint struct {
	Position
	Expression Expression
}

func (*CheckConstraint) Accept

func (c *CheckConstraint) Accept(v Visitor) any

func (*CheckConstraint) LocalColumns

func (c *CheckConstraint) LocalColumns() []string

type Column

type Column struct {
	Position

	Name        string
	Type        *types.DataType
	Constraints []InlineConstraint
}

Column represents a table column.

func (*Column) Accept

func (c *Column) Accept(v Visitor) any

type CommonTableExpression

type CommonTableExpression struct {
	Position
	// Name is the name of the CTE.
	Name string
	// Columns are the columns of the CTE.
	Columns []string
	// Query is the query of the CTE.
	Query *SelectStatement
}

CommonTableExpression is a common table expression.

func (*CommonTableExpression) Accept

func (c *CommonTableExpression) Accept(v Visitor) any

type ComparisonOperator

type ComparisonOperator string
const (
	ComparisonOperatorEqual              ComparisonOperator = "="
	ComparisonOperatorNotEqual           ComparisonOperator = "<>"
	ComparisonOperatorGreaterThan        ComparisonOperator = ">"
	ComparisonOperatorLessThan           ComparisonOperator = "<"
	ComparisonOperatorGreaterThanOrEqual ComparisonOperator = ">="
	ComparisonOperatorLessThanOrEqual    ComparisonOperator = "<="
)

type CompoundOperator

type CompoundOperator string
const (
	CompoundOperatorUnion     CompoundOperator = "UNION"
	CompoundOperatorUnionAll  CompoundOperator = "UNION ALL"
	CompoundOperatorIntersect CompoundOperator = "INTERSECT"
	CompoundOperatorExcept    CompoundOperator = "EXCEPT"
)

type ConstraintType

type ConstraintType interface {
	String() string
	// contains filtered or unexported methods
}

ConstraintType is a constraint in a table.

type CreateActionStatement

type CreateActionStatement struct {
	Position
	Namespacing
	// Either IfNotExists or OrReplace can be true, but not both.
	// Both can be false.
	IfNotExists bool
	OrReplace   bool

	// Name is the name of the action.
	Name string

	// Parameters are the parameters of the action.
	Parameters []*engine.NamedType

	// Modifiers are things like VIEW, OWNER, etc.
	Modifiers []string
	// Returns specifies the return type of the action.
	// It can be nil if the action does not return anything.
	Returns *ActionReturn
	// Statements are the statements in the action.
	Statements []ActionStmt
	// Raw is the raw CREATE ACTION statement.
	Raw string
}

CreateActionStatement is a CREATE ACTION statement.

func (*CreateActionStatement) Accept

func (c *CreateActionStatement) Accept(v Visitor) any

type CreateIndexStatement

type CreateIndexStatement struct {
	Position
	Namespacing
	IfNotExists bool
	Name        string
	On          string
	Columns     []string
	Type        IndexType
}

func (*CreateIndexStatement) Accept

func (s *CreateIndexStatement) Accept(v Visitor) any

type CreateNamespaceStatement

type CreateNamespaceStatement struct {
	Position
	// IfNotExists is true if the IF NOT EXISTS clause is present.
	IfNotExists bool
	// Namespace is the namespace that is being created.
	Namespace string
}

func (*CreateNamespaceStatement) Accept

func (c *CreateNamespaceStatement) Accept(v Visitor) any

type CreateRoleStatement

type CreateRoleStatement struct {
	Position
	// IfNotExists is true if the IF NOT EXISTS clause is present.
	IfNotExists bool
	// Role is the role that is being created or dropped.
	Role string
}

func (*CreateRoleStatement) Accept

func (c *CreateRoleStatement) Accept(v Visitor) any

type CreateTableStatement

type CreateTableStatement struct {
	Position
	Namespacing
	IfNotExists bool
	Name        string
	Columns     []*Column
	// Constraints contains the non-inline constraints
	Constraints []*OutOfLineConstraint
}

CreateTableStatement is a CREATE TABLE statement.

func (*CreateTableStatement) Accept

func (c *CreateTableStatement) Accept(v Visitor) any

type DDLVisitor

type DDLVisitor interface {
	// DDL
	VisitCreateTableStatement(*CreateTableStatement) any
	VisitAlterTableStatement(*AlterTableStatement) any
	VisitDropTableStatement(*DropTableStatement) any
	VisitCreateIndexStatement(*CreateIndexStatement) any
	VisitDropIndexStatement(*DropIndexStatement) any
	VisitGrantOrRevokeStatement(*GrantOrRevokeStatement) any
	VisitTransferOwnershipStatement(*TransferOwnershipStatement) any
	VisitAlterColumnSet(*AlterColumnSet) any
	VisitAlterColumnDrop(*AlterColumnDrop) any
	VisitAddColumn(*AddColumn) any
	VisitDropColumn(*DropColumn) any
	VisitRenameColumn(*RenameColumn) any
	VisitRenameTable(*RenameTable) any
	VisitAddTableConstraint(*AddTableConstraint) any
	VisitDropTableConstraint(*DropTableConstraint) any
	VisitColumn(*Column) any
	VisitCreateRoleStatement(*CreateRoleStatement) any
	VisitDropRoleStatement(*DropRoleStatement) any
	VisitUseExtensionStatement(*UseExtensionStatement) any
	VisitUnuseExtensionStatement(*UnuseExtensionStatement) any
	VisitCreateNamespaceStatement(*CreateNamespaceStatement) any
	VisitDropNamespaceStatement(*DropNamespaceStatement) any
	VisitSetCurrentNamespaceStatement(*SetCurrentNamespaceStatement) any
	VisitCreateActionStatement(*CreateActionStatement) any
	VisitDropActionStatement(*DropActionStatement) any
	// Constraints
	VisitPrimaryKeyInlineConstraint(*PrimaryKeyInlineConstraint) any
	VisitPrimaryKeyOutOfLineConstraint(*PrimaryKeyOutOfLineConstraint) any
	VisitUniqueInlineConstraint(*UniqueInlineConstraint) any
	VisitUniqueOutOfLineConstraint(*UniqueOutOfLineConstraint) any
	VisitDefaultConstraint(*DefaultConstraint) any
	VisitNotNullConstraint(*NotNullConstraint) any
	VisitCheckConstraint(*CheckConstraint) any
	VisitForeignKeyReferences(*ForeignKeyReferences) any
	VisitForeignKeyOutOfLineConstraint(*ForeignKeyOutOfLineConstraint) any
}

DDLVisitor includes visit methods only needed to analyze DDL statements.

type DefaultConstraint

type DefaultConstraint struct {
	Position
	Value Expression
}

func (*DefaultConstraint) Accept

func (c *DefaultConstraint) Accept(v Visitor) any

type DeleteStatement

type DeleteStatement struct {
	Position

	Table string
	Alias string     // can be empty
	From  Table      // can be nil
	Joins []*Join    // can be nil
	Where Expression // can be nil
}

func (*DeleteStatement) Accept

func (d *DeleteStatement) Accept(v Visitor) any

type DropActionStatement

type DropActionStatement struct {
	Position
	Namespacing
	// IfExists is true if the IF EXISTS clause is present.
	IfExists bool
	// Name is the name of the action.
	Name string
}

func (*DropActionStatement) Accept

func (d *DropActionStatement) Accept(v Visitor) any

type DropBehavior

type DropBehavior string
const (
	DropBehaviorDefault  DropBehavior = ""
	DropBehaviorCascade  DropBehavior = "CASCADE"
	DropBehaviorRestrict DropBehavior = "RESTRICT"
)

type DropColumn

type DropColumn struct {
	Position
	Name     string
	IfExists bool
}

func (*DropColumn) Accept

func (a *DropColumn) Accept(v Visitor) any

type DropIndexStatement

type DropIndexStatement struct {
	Position
	Namespacing
	Name       string
	CheckExist bool
}

func (*DropIndexStatement) Accept

func (s *DropIndexStatement) Accept(v Visitor) any

type DropNamespaceStatement

type DropNamespaceStatement struct {
	Position
	// IfExists is true if the IF EXISTS clause is present.
	IfExists bool
	// Namespace is the namespace that is being dropped.
	Namespace string
}

func (*DropNamespaceStatement) Accept

func (d *DropNamespaceStatement) Accept(v Visitor) any

type DropRoleStatement

type DropRoleStatement struct {
	Position
	// IfExists is true if the IF EXISTS clause is present.
	IfExists bool
	// Role is the role that is being created or dropped.
	Role string
}

func (*DropRoleStatement) Accept

func (d *DropRoleStatement) Accept(v Visitor) any

type DropTableConstraint

type DropTableConstraint struct {
	Position
	Name     string
	IfExists bool
}

func (*DropTableConstraint) Accept

func (a *DropTableConstraint) Accept(v Visitor) any

type DropTableStatement

type DropTableStatement struct {
	Position
	Namespacing
	Tables   []string
	IfExists bool
	Behavior DropBehavior
}

func (*DropTableStatement) Accept

func (s *DropTableStatement) Accept(v Visitor) any

type Expression

type Expression interface {
	Node
}

Expression is an interface for all expressions.

type ExpressionArithmetic

type ExpressionArithmetic struct {
	Position
	// Left is the left side of the arithmetic expression.
	Left Expression
	// Right is the right side of the arithmetic expression.
	Right Expression
	// Operator is the operator of the arithmetic expression.
	Operator ArithmeticOperator
}

ExpressionArithmetic is an arithmetic expression.

func (*ExpressionArithmetic) Accept

func (e *ExpressionArithmetic) Accept(v Visitor) any

type ExpressionArrayAccess

type ExpressionArrayAccess struct {
	Position
	Typecastable
	// Array is the array that is being accessed.
	Array Expression
	// Index is the index that is being accessed.
	// Either Index or FromTo is set, but not both.
	Index Expression
	// FromTo is the range that is being accessed.
	// Either Index or FromTo is set, but not both.
	// If FromTo is set, then it is a range access.
	// If both values are set, then it is arr[FROM:TO].
	// If only From is set, then it is arr[FROM:].
	// If only To is set, then it is arr[:TO].
	// If neither are set and index is not set, then it is arr[:].
	FromTo *[2]Expression
}

ExpressionArrayAccess accesses an array value.

func (*ExpressionArrayAccess) Accept

func (e *ExpressionArrayAccess) Accept(v Visitor) any

type ExpressionBetween

type ExpressionBetween struct {
	Position
	// Expression is the expression that is being compared.
	Expression Expression
	// Lower is the left side of the BETWEEN expression.
	Lower Expression
	// Upper is the right side of the BETWEEN expression.
	Upper Expression
	// Not is true if the BETWEEN expression is a NOT BETWEEN expression.
	Not bool
}

ExpressionBetween is a BETWEEN expression.

func (*ExpressionBetween) Accept

func (e *ExpressionBetween) Accept(v Visitor) any

type ExpressionCase

type ExpressionCase struct {
	Position
	Case     Expression
	WhenThen [][2]Expression
	Else     Expression
}

ExpressionCase is a CASE expression.

func (*ExpressionCase) Accept

func (e *ExpressionCase) Accept(v Visitor) any

type ExpressionCollate

type ExpressionCollate struct {
	Position
	// Expression is the expression that is being collated.
	Expression Expression
	// Collation is the collation that is being used.
	Collation string
}

ExpressionCollate is an expression with a collation.

func (*ExpressionCollate) Accept

func (e *ExpressionCollate) Accept(v Visitor) any

type ExpressionColumn

type ExpressionColumn struct {
	Position
	Typecastable
	// Table is the table that the column is in.
	Table string // can be empty
	// Column is the name of the column.
	Column string
}

ExpressionColumn is a column in a table.

func (*ExpressionColumn) Accept

func (e *ExpressionColumn) Accept(v Visitor) any

func (*ExpressionColumn) String

func (e *ExpressionColumn) String() string

type ExpressionComparison

type ExpressionComparison struct {
	Position
	// Left is the left side of the comparison.
	Left Expression
	// Right is the right side of the comparison.
	Right Expression
	// Operator is the operator of the comparison.
	Operator ComparisonOperator
}

ExpressionComparison is a comparison expression.

func (*ExpressionComparison) Accept

func (e *ExpressionComparison) Accept(v Visitor) any

type ExpressionFieldAccess

type ExpressionFieldAccess struct {
	Position
	Typecastable
	// Record is the record that is being accessed.
	Record Expression
	// Field is the field that is being accessed.
	Field string
}

ExpressionFieldAccess accesses a field in a record.

func (*ExpressionFieldAccess) Accept

func (e *ExpressionFieldAccess) Accept(v Visitor) any

type ExpressionFunctionCall

type ExpressionFunctionCall struct {
	Position
	Typecastable
	// Namespace is the namespace/schema that the function is in.
	// It can be empty if the function is in the default namespace.
	Namespace string
	// Name is the name of the function.
	Name string
	// Args are the arguments to the function call.
	// They are passed using ()
	Args []Expression
	// Distinct is true if the function call is a DISTINCT function call.
	Distinct bool
	// Star is true if the function call is a * function call.
	// If it is set, then Args must be empty.
	Star bool
}

ExpressionFunctionCall is a function call expression.

func (*ExpressionFunctionCall) Accept

func (e *ExpressionFunctionCall) Accept(v Visitor) any

type ExpressionIn

type ExpressionIn struct {
	Position
	// Expression is the expression that is being compared.
	Expression Expression
	// List is the list of expressions that the expression is being compared to.
	// Either List or Subquery is set, but not both.
	List []Expression
	// Subquery is the subquery that the expression is being compared to.
	// Either List or Subquery is set, but not both.
	Subquery *SelectStatement
	// Not is true if the IN expression is a NOT IN expression.
	Not bool
}

func (*ExpressionIn) Accept

func (e *ExpressionIn) Accept(v Visitor) any

type ExpressionIs

type ExpressionIs struct {
	Position
	// Left is the left side of the IS expression.
	Left Expression
	// Right is the right side of the IS expression.
	Right Expression
	// Not is true if the IS expression is a NOT IS expression.
	Not bool
	// Distinct is true if the IS expression is a DISTINCT IS expression.
	Distinct bool
}

ExpressionIs is an IS expression.

func (*ExpressionIs) Accept

func (e *ExpressionIs) Accept(v Visitor) any

type ExpressionLiteral

type ExpressionLiteral struct {
	Position
	Typecastable
	Type *types.DataType
	// Value is the value of the literal.
	// It must be of type string, int64, bool, *decimal.Decimal,
	// or nil
	Value any
}

ExpressionLiteral is a literal expression.

func (*ExpressionLiteral) Accept

func (e *ExpressionLiteral) Accept(v Visitor) any

func (*ExpressionLiteral) String

func (e *ExpressionLiteral) String() string

String returns the string representation of the literal.

type ExpressionLogical

type ExpressionLogical struct {
	Position
	// Left is the left side of the logical expression.
	Left Expression
	// Right is the right side of the logical expression.
	Right Expression
	// Operator is the operator of the logical expression.
	Operator LogicalOperator
}

ExpressionLogical is a logical expression.

func (*ExpressionLogical) Accept

func (e *ExpressionLogical) Accept(v Visitor) any

type ExpressionMakeArray

type ExpressionMakeArray struct {
	Position
	Typecastable
	Values []Expression
}

ExpressionMakeArray makes a new array.

func (*ExpressionMakeArray) Accept

func (e *ExpressionMakeArray) Accept(v Visitor) any

type ExpressionParenthesized

type ExpressionParenthesized struct {
	Position
	Typecastable
	// Inner is the inner expression.
	Inner Expression
}

ExpressionParenthesized is a parenthesized expression.

func (*ExpressionParenthesized) Accept

func (e *ExpressionParenthesized) Accept(v Visitor) any

type ExpressionStringComparison

type ExpressionStringComparison struct {
	Position
	// Left is the left side of the comparison.
	Left Expression
	// Right is the right side of the comparison.
	Right Expression
	Not   bool
	// Operator is the operator of the comparison.
	Operator StringComparisonOperator
}

ExpressionStringComparison is a string comparison expression.

func (*ExpressionStringComparison) Accept

func (e *ExpressionStringComparison) Accept(v Visitor) any

type ExpressionSubquery

type ExpressionSubquery struct {
	Position
	Typecastable
	Not      bool
	Exists   bool
	Subquery *SelectStatement
}

ExpressionSubquery is a subquery expression.

func (*ExpressionSubquery) Accept

func (e *ExpressionSubquery) Accept(v Visitor) any

type ExpressionUnary

type ExpressionUnary struct {
	Position
	// Expression is the expression that is being operated on.
	Expression Expression
	// Operator is the operator of the unary expression.
	Operator UnaryOperator
}

func (*ExpressionUnary) Accept

func (e *ExpressionUnary) Accept(v Visitor) any

type ExpressionVariable

type ExpressionVariable struct {
	Position
	Typecastable
	// Name is the naem of the variable,
	// without the $ or @.
	Name string
	// Prefix is the $ or @ prefix.
	Prefix VariablePrefix
}

ExpressionVariable is a variable. This can either be $ or @ variables.

func (*ExpressionVariable) Accept

func (e *ExpressionVariable) Accept(v Visitor) any

func (*ExpressionVariable) String

func (e *ExpressionVariable) String() string

String returns the string representation, as it was passed in Kuneiform.

type ExpressionWindowFunctionCall

type ExpressionWindowFunctionCall struct {
	Position
	FunctionCall *ExpressionFunctionCall
	// Filter is the filter clause.
	// If nil, then there is no filter clause.
	Filter Expression
	// Window is the window function that is being called.
	Window Window
}

ExpressionWindowFunctionCall is a window function call expression.

func (*ExpressionWindowFunctionCall) Accept

type ForeignKey

type ForeignKey struct {
	// ChildKeys are the columns that are referencing another.
	// For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "a" is the child key
	ChildKeys []string `json:"child_keys"`

	// ParentKeys are the columns that are being referred to.
	// For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "b" is the parent key
	ParentKeys []string `json:"parent_keys"`

	// ParentTable is the table that holds the parent columns.
	// For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "tbl2" is the parent table
	ParentTable string `json:"parent_table"`

	// Action refers to what the foreign key should do when the parent is altered.
	// This is NOT the same as a database action.
	// For example, ON DELETE CASCADE is a foreign key action
	Actions []*ForeignKeyAction `json:"actions"`
}

ForeignKey is a foreign key in a table.

type ForeignKeyAction

type ForeignKeyAction struct {
	// On can be either "UPDATE" or "DELETE"
	On ForeignKeyActionOn `json:"on"`

	// Do specifies what a foreign key action should do
	Do ForeignKeyActionDo `json:"do"`
}

ForeignKeyAction is used to specify what should occur if a parent key is updated or deleted

type ForeignKeyActionDo

type ForeignKeyActionDo string

ForeignKeyActionDo specifies what should be done when a foreign key action is triggered.

const (
	// DO_NO_ACTION does nothing when a parent key is altered
	DO_NO_ACTION ForeignKeyActionDo = "NO ACTION"

	// DO_RESTRICT prevents the parent key from being altered
	DO_RESTRICT ForeignKeyActionDo = "RESTRICT"

	// DO_SET_NULL sets the child key(s) to NULL
	DO_SET_NULL ForeignKeyActionDo = "SET NULL"

	// DO_SET_DEFAULT sets the child key(s) to their default values
	DO_SET_DEFAULT ForeignKeyActionDo = "SET DEFAULT"

	// DO_CASCADE updates the child key(s) or deletes the records (depending on the action type)
	DO_CASCADE ForeignKeyActionDo = "CASCADE"
)

ForeignKeyActionDo types

type ForeignKeyActionOn

type ForeignKeyActionOn string

ForeignKeyActionOn specifies when a foreign key action should occur. It can be either "UPDATE" or "DELETE".

const (
	// ON_UPDATE is used to specify an action should occur when a parent key is updated
	ON_UPDATE ForeignKeyActionOn = "UPDATE"
	// ON_DELETE is used to specify an action should occur when a parent key is deleted
	ON_DELETE ForeignKeyActionOn = "DELETE"
)

ForeignKeyActionOn types

type ForeignKeyOutOfLineConstraint

type ForeignKeyOutOfLineConstraint struct {
	Position
	Columns    []string
	References *ForeignKeyReferences
}

func (*ForeignKeyOutOfLineConstraint) Accept

func (*ForeignKeyOutOfLineConstraint) LocalColumns

func (c *ForeignKeyOutOfLineConstraint) LocalColumns() []string

type ForeignKeyReferences

type ForeignKeyReferences struct {
	Position

	// RefTableNamespace is the qualifier of the referenced table.
	// It can be empty if the table is in the same schema.
	RefTableNamespace string
	RefTable          string
	RefColumns        []string
	Actions           []*ForeignKeyAction
}

func (*ForeignKeyReferences) Accept

func (c *ForeignKeyReferences) Accept(v Visitor) any

type GetPositioner

type GetPositioner interface {
	GetPosition() *Position
	Clear()
}

type GrantOrRevokeStatement

type GrantOrRevokeStatement struct {
	Position
	// If is true if either IF GRANTED or IF NOT GRANTED is present,
	// depending on the statement.
	If bool
	// IsGrant is true if the statement is a GRANT statement.
	// If it is false, then it is a REVOKE statement.
	IsGrant bool
	// Privileges are the privileges that are being granted.
	// Either Privileges or Role must be set, but not both.
	Privileges []string
	// Namespace is the namespace that the privileges are being granted on.
	// It can be nil if they are global.
	Namespace *string
	// OnNam
	// Role is the role being granted
	// Either Privileges or Role must be set, but not both.
	GrantRole string
	// ToRole is the role being granted to.
	// Only one of ToUser, ToRole, or ToVariable must be set.
	ToRole string
	// ToUser is the user being granted to.
	// Only one of ToUser, ToRole, or ToVariable must be set.
	ToUser string
	// ToVariable is the variable being granted to.
	// Only one of ToUser, ToRole, or ToVariable must be set.
	ToVariable Expression
}

func (*GrantOrRevokeStatement) Accept

func (g *GrantOrRevokeStatement) Accept(v Visitor) any

type IfThen

type IfThen struct {
	Position
	If   Expression
	Then []ActionStmt
}

func (*IfThen) Accept

func (i *IfThen) Accept(v Visitor) any

type IndexType

type IndexType string
const (
	// IndexTypeBTree is the default index, created by using `INDEX`.
	IndexTypeBTree IndexType = "BTREE"
	// IndexTypeUnique is a unique BTree index, created by using `UNIQUE INDEX`.
	IndexTypeUnique IndexType = "UNIQUE"
)

type InlineConstraint

type InlineConstraint interface {
	Node
	// contains filtered or unexported methods
}

InlineConstraint is a constraint that is inline with the column.

type InsertStatement

type InsertStatement struct {
	Position
	Table   string
	Alias   string   // can be empty
	Columns []string // can be empty
	// Either Values or Select is set, but not both.
	Values     [][]Expression   // can be empty
	Select     *SelectStatement // can be nil
	OnConflict *OnConflict      // can be nil
}

func (*InsertStatement) Accept

func (i *InsertStatement) Accept(v Visitor) any

type Join

type Join struct {
	Position
	Type     JoinType
	Relation Table
	On       Expression
}

Join is a join in a SELECT statement.

func (*Join) Accept

func (j *Join) Accept(v Visitor) any

type JoinType

type JoinType string
const (
	JoinTypeInner JoinType = "INNER"
	JoinTypeLeft  JoinType = "LEFT"
	JoinTypeRight JoinType = "RIGHT"
	JoinTypeFull  JoinType = "FULL"
)

type LogicalOperator

type LogicalOperator string
const (
	LogicalOperatorAnd LogicalOperator = "AND"
	LogicalOperatorOr  LogicalOperator = "OR"
)

type LoopControlType

type LoopControlType string
const (
	LoopControlTypeBreak    LoopControlType = "BREAK"
	LoopControlTypeContinue LoopControlType = "CONTINUE"
)

type LoopTerm

type LoopTerm interface {
	Node
	// contains filtered or unexported methods
}

LoopTerm what the loop is looping through.

type LoopTermExpression

type LoopTermExpression struct {

	// If Array is true, then the ARRAY keyword was used, specifying that
	// the function is expected to return a single array, and we should loop
	// through each element in the array.
	Array bool
	// Expression is the expression to loop through.
	Expression Expression
	// contains filtered or unexported fields
}

LoopTermExpression is a loop term that loops over an expression.

func (*LoopTermExpression) Accept

func (e *LoopTermExpression) Accept(v Visitor) interface{}

type LoopTermRange

type LoopTermRange struct {

	// Start is the start of the range.
	Start Expression
	// End is the end of the range.
	End Expression
	// contains filtered or unexported fields
}

func (*LoopTermRange) Accept

func (e *LoopTermRange) Accept(v Visitor) interface{}

type LoopTermSQL

type LoopTermSQL struct {

	// Statement is the Statement statement to execute.
	Statement *SQLStatement
	// contains filtered or unexported fields
}

func (*LoopTermSQL) Accept

func (e *LoopTermSQL) Accept(v Visitor) interface{}

type MultiColumnConstraintType

type MultiColumnConstraintType string
const (
	ConstraintTypeUnique     MultiColumnConstraintType = "UNIQUE"
	ConstraintTypeCheck      MultiColumnConstraintType = "CHECK"
	ConstraintTypeForeignKey MultiColumnConstraintType = "FOREIGN KEY"
	ConstraintTypePrimaryKey MultiColumnConstraintType = "PRIMARY KEY"
)

func (MultiColumnConstraintType) String

func (t MultiColumnConstraintType) String() string

type Namespaceable

type Namespaceable interface {
	TopLevelStatement
	SetNamespacePrefix(string)
	GetNamespacePrefix() string
}

type Namespacing

type Namespacing struct {
	NamespacePrefix string
}

Namespacing is a struct that can have a namespace prefix. This is used for top-level statements that can have a namespace prefix using curly braces.

func (*Namespacing) GetNamespacePrefix

func (n *Namespacing) GetNamespacePrefix() string

func (*Namespacing) SetNamespacePrefix

func (n *Namespacing) SetNamespacePrefix(prefix string)

type Node

type Node interface {
	Positionable
	Accept(Visitor) any
}

Node is a node in the AST.

type NotNullConstraint

type NotNullConstraint struct {
	Position
}

func (*NotNullConstraint) Accept

func (c *NotNullConstraint) Accept(v Visitor) any

type NullOrder

type NullOrder string
const (
	NullOrderFirst NullOrder = "FIRST"
	NullOrderLast  NullOrder = "LAST"
)

type OnConflict

type OnConflict struct {
	Position
	ConflictColumns []string           // can be empty
	ConflictWhere   Expression         // can be nil
	DoUpdate        []*UpdateSetClause // if nil, then do nothing
	UpdateWhere     Expression         // can be nil
}

func (*OnConflict) Accept

func (u *OnConflict) Accept(v Visitor) any

type OrderType

type OrderType string
const (
	OrderTypeAsc  OrderType = "ASC"
	OrderTypeDesc OrderType = "DESC"
)

type OrderingTerm

type OrderingTerm struct {
	Position
	Expression Expression
	Order      OrderType
	Nulls      NullOrder
}

OrderingTerm is a term in an order by clause

func (*OrderingTerm) Accept

func (o *OrderingTerm) Accept(v Visitor) any

type OutOfLineConstraint

type OutOfLineConstraint struct {
	Position
	Name       string // can be empty if the name should be auto-generated
	Constraint OutOfLineConstraintClause
}

OutOfLineConstraint is a constraint that is not inline with the column. e.g. CREATE TABLE t (a INT, CONSTRAINT c CHECK (a > 0))

type OutOfLineConstraintClause

type OutOfLineConstraintClause interface {
	Node

	// LocalColumns returns the local columns that the constraint is applied to.
	LocalColumns() []string
	// contains filtered or unexported methods
}

OutOfLineConstraintClause is a constraint that is not inline with the column.

type ParseError

type ParseError struct {
	ParserName string    `json:"parser_name,omitempty"`
	Err        error     `json:"error"`
	Message    string    `json:"message,omitempty"`
	Position   *Position `json:"position,omitempty"`
}

ParseError is an error that occurred during parsing.

func (*ParseError) Error

func (p *ParseError) Error() string

Error satisfies the standard library error interface.

func (*ParseError) MarshalJSON

func (p *ParseError) MarshalJSON() ([]byte, error)

MarshalJSON marshals the error to JSON.

func (ParseError) Unwrap

func (p ParseError) Unwrap() error

Unwrap() allows errors.Is and errors.As to find wrapped errors.

type ParseErrs

type ParseErrs interface {
	Err() error
	Errors() []*ParseError
	Add(...*ParseError)
	MarshalJSON() ([]byte, error)
}

ParseErrs is a collection of parse errors.

func WrapErrors

func WrapErrors(errs ...*ParseError) ParseErrs

WrapErrors wraps a collection of ParseErrors

type ParseResult

type ParseResult struct {
	// Statements are the individual statements, in the order they were encountered.
	Statements []TopLevelStatement `json:"statements,omitempty"`
	// ParseErrs is the error listener that contains all the errors that occurred during parsing.
	ParseErrs ParseErrs `json:"parse_errs,omitempty"`
}

ParseResult is the result of parsing a SQL statement. It can be any statement, including: - CREATE TABLE - SELECT/INSERT/UPDATE/DELETE - CREATE ACTION - etc.

func ParseWithErrListener

func ParseWithErrListener(sql string) (p *ParseResult, err error)

ParseWithErrListener parses a statement or set of statements separated by semicolons. It returns the parsed statements, as well as an error listener with position information. Public consumers should opt for Parse instead, unless there is a specific need for the error listener.

func (*ParseResult) Err

func (r *ParseResult) Err() error

type Position

type Position struct {
	StartLine *int `json:"start_line,omitempty"`
	StartCol  *int `json:"start_col,omitempty"`
	EndLine   *int `json:"end_line,omitempty"`
	EndCol    *int `json:"end_col,omitempty"`
	// contains filtered or unexported fields
}

Position is a Position in the parse tree. It represents a range of line and column values in Kuneiform source code.

func (*Position) Clear

func (n *Position) Clear()

Clear clears the position of the Position.

func (*Position) GetPosition

func (n *Position) GetPosition() *Position

GetPosition returns the Position. It is useful if the Position is embedded in another struct.

func (*Position) Set

func (n *Position) Set(r antlr.ParserRuleContext)

Set sets the position of the Position based on the given parser rule context.

func (*Position) SetToken

func (n *Position) SetToken(t antlr.Token)

SetToken sets the position of the Position based on the given token.

type Positionable

type Positionable interface {
	GetPositioner
	Set(r antlr.ParserRuleContext)
	SetToken(t antlr.Token)
}

type PrimaryKeyInlineConstraint

type PrimaryKeyInlineConstraint struct {
	Position
}

func (*PrimaryKeyInlineConstraint) Accept

func (c *PrimaryKeyInlineConstraint) Accept(v Visitor) any

type PrimaryKeyOutOfLineConstraint

type PrimaryKeyOutOfLineConstraint struct {
	Position
	Columns []string
}

func (*PrimaryKeyOutOfLineConstraint) Accept

func (*PrimaryKeyOutOfLineConstraint) LocalColumns

func (c *PrimaryKeyOutOfLineConstraint) LocalColumns() []string

type RelationSubquery

type RelationSubquery struct {
	Position
	Subquery *SelectStatement
	// Alias cannot be empty, as our syntax
	// forces it for subqueries.
	Alias string
}

func (*RelationSubquery) Accept

func (r *RelationSubquery) Accept(v Visitor) any

type RelationTable

type RelationTable struct {
	Position
	// Namespace is the namespace of the table.
	// If it is empty, then the table is in the current namespace.
	Namespace string
	// Table is the name of the table.
	Table string
	Alias string // can be empty
}

func (*RelationTable) Accept

func (r *RelationTable) Accept(v Visitor) any

type RenameColumn

type RenameColumn struct {
	Position
	OldName string
	NewName string
}

func (*RenameColumn) Accept

func (a *RenameColumn) Accept(v Visitor) any

type RenameTable

type RenameTable struct {
	Position
	Name string
}

func (*RenameTable) Accept

func (a *RenameTable) Accept(v Visitor) any

type ResultColumn

type ResultColumn interface {
	Node
	ResultColumnType() ResultColumnType
}

type ResultColumnExpression

type ResultColumnExpression struct {
	Position

	Expression Expression
	Alias      string // can be empty
}

func (*ResultColumnExpression) Accept

func (r *ResultColumnExpression) Accept(v Visitor) any

func (*ResultColumnExpression) ResultColumnType

func (r *ResultColumnExpression) ResultColumnType() ResultColumnType

type ResultColumnType

type ResultColumnType string
const (
	ResultColumnTypeExpression ResultColumnType = "expression"
	ResultColumnTypeWildcard   ResultColumnType = "wildcare"
)

type ResultColumnWildcard

type ResultColumnWildcard struct {
	Position
	Table string // can be empty
}

func (*ResultColumnWildcard) Accept

func (r *ResultColumnWildcard) Accept(v Visitor) any

func (*ResultColumnWildcard) ResultColumnType

func (r *ResultColumnWildcard) ResultColumnType() ResultColumnType

type SQLCore

type SQLCore interface {
	Node
	// contains filtered or unexported methods
}

SQLCore is a DML statement. It can be INSERT, UPDATE, DELETE, SELECT.

type SQLStatement

type SQLStatement struct {
	Position
	Namespacing
	CTEs []*CommonTableExpression
	// Recursive is true if the RECURSIVE keyword is present.
	Recursive bool
	// SQL can be an insert, update, delete, or select statement.
	SQL SQLCore
	// contains filtered or unexported fields
}

SQLStatement is a DML statement with common table expression.

func (*SQLStatement) Accept

func (s *SQLStatement) Accept(v Visitor) any

func (*SQLStatement) Raw

func (s *SQLStatement) Raw() (string, error)

type SQLVisitor

type SQLVisitor interface {
	VisitExpressionLiteral(*ExpressionLiteral) any
	VisitExpressionFunctionCall(*ExpressionFunctionCall) any
	VisitExpressionWindowFunctionCall(*ExpressionWindowFunctionCall) any
	VisitWindowImpl(*WindowImpl) any
	VisitWindowReference(*WindowReference) any
	VisitExpressionVariable(*ExpressionVariable) any
	VisitExpressionArrayAccess(*ExpressionArrayAccess) any
	VisitExpressionMakeArray(*ExpressionMakeArray) any
	VisitExpressionFieldAccess(*ExpressionFieldAccess) any
	VisitExpressionParenthesized(*ExpressionParenthesized) any
	VisitExpressionComparison(*ExpressionComparison) any
	VisitExpressionLogical(*ExpressionLogical) any
	VisitExpressionArithmetic(*ExpressionArithmetic) any
	VisitExpressionUnary(*ExpressionUnary) any
	VisitExpressionColumn(*ExpressionColumn) any
	VisitExpressionCollate(*ExpressionCollate) any
	VisitExpressionStringComparison(*ExpressionStringComparison) any
	VisitExpressionIs(*ExpressionIs) any
	VisitExpressionIn(*ExpressionIn) any
	VisitExpressionBetween(*ExpressionBetween) any
	VisitExpressionSubquery(*ExpressionSubquery) any
	VisitExpressionCase(*ExpressionCase) any
	VisitCommonTableExpression(*CommonTableExpression) any
	VisitSQLStatement(*SQLStatement) any
	VisitSelectStatement(*SelectStatement) any
	VisitSelectCore(*SelectCore) any
	VisitResultColumnExpression(*ResultColumnExpression) any
	VisitResultColumnWildcard(*ResultColumnWildcard) any
	VisitRelationTable(*RelationTable) any
	VisitRelationSubquery(*RelationSubquery) any
	VisitJoin(*Join) any
	VisitUpdateStatement(*UpdateStatement) any
	VisitUpdateSetClause(*UpdateSetClause) any
	VisitDeleteStatement(*DeleteStatement) any
	VisitInsertStatement(*InsertStatement) any
	VisitUpsertClause(*OnConflict) any
	VisitOrderingTerm(*OrderingTerm) any
}

SQLVisitor is a visitor that only has methods for SQL nodes.

type SelectCore

type SelectCore struct {
	Position
	// Distinct is true if the SELECT statement is a DISTINCT SELECT statement.
	Distinct bool
	Columns  []ResultColumn
	From     Table        // can be nil
	Joins    []*Join      // can be nil
	Where    Expression   // can be nil
	GroupBy  []Expression // can be nil
	Having   Expression   // can be nil
	Windows  []*struct {
		Name   string
		Window *WindowImpl
	} // can be nil
}

func (*SelectCore) Accept

func (s *SelectCore) Accept(v Visitor) any

type SelectStatement

type SelectStatement struct {
	Position
	SelectCores       []*SelectCore
	CompoundOperators []CompoundOperator
	Ordering          []*OrderingTerm
	Limit             Expression
	Offset            Expression
}

SelectStatement is a SELECT statement.

func (*SelectStatement) Accept

func (s *SelectStatement) Accept(v Visitor) any

type SetCurrentNamespaceStatement

type SetCurrentNamespaceStatement struct {
	Position
	Namespace string
}

func (*SetCurrentNamespaceStatement) Accept

type SingleColumnConstraintType

type SingleColumnConstraintType string

SingleColumnConstraintType is a constraint type that can only ever be applied to a single column. These are NOT NULL and DEFAULT.

const (
	ConstraintTypeNotNull SingleColumnConstraintType = "NOT NULL"
	ConstraintTypeDefault SingleColumnConstraintType = "DEFAULT"
)

func (SingleColumnConstraintType) String

type StringComparisonOperator

type StringComparisonOperator string
const (
	StringComparisonOperatorLike  StringComparisonOperator = "LIKE"
	StringComparisonOperatorILike StringComparisonOperator = "ILIKE"
)

type Table

type Table interface {
	Node
	// contains filtered or unexported methods
}

type TopLevelStatement

type TopLevelStatement interface {
	Node
	// contains filtered or unexported methods
}

TopLevelStatement is a top-level statement. By itself, it is a valid statement.

func Parse

func Parse(sql string) (t []TopLevelStatement, err error)

Parse parses a statement or set of statements separated by semicolons.

type TransferOwnershipStatement

type TransferOwnershipStatement struct {
	Position
	// ToUser is the user that the ownership is being transferred to.
	ToUser string
	// ToVariable is the variable that the ownership is being transferred to.
	ToVariable Expression
}

func (*TransferOwnershipStatement) Accept

func (t *TransferOwnershipStatement) Accept(v Visitor) any

type Typecastable

type Typecastable struct {
	TypeCast *types.DataType
}

func (*Typecastable) Cast

func (t *Typecastable) Cast(t2 *types.DataType)

func (*Typecastable) GetTypeCast

func (t *Typecastable) GetTypeCast() *types.DataType

type Typecasted

type Typecasted interface {
	GetTypeCast() *types.DataType
}

type UnaryOperator

type UnaryOperator string
const (
	// Not can be either NOT or !
	UnaryOperatorNot UnaryOperator = "NOT"
	UnaryOperatorNeg UnaryOperator = "-"
	UnaryOperatorPos UnaryOperator = "+"
)

type UnimplementedActionVisitor

type UnimplementedActionVisitor struct{}

UnimplementedActionVisitor is meant to be used when an implementing visitor only intends to implement the ActionVisitor interface. It will implement the full visitor interface, but will panic if any of the methods are called. It does not implement the SQLVisitor or ActionVisitor interfaces, so it alone cannot be used as a visitor.

func (*UnimplementedActionVisitor) VisitActionStmtAssignment

func (s *UnimplementedActionVisitor) VisitActionStmtAssignment(p0 *ActionStmtAssign) any

func (*UnimplementedActionVisitor) VisitActionStmtBreak

func (s *UnimplementedActionVisitor) VisitActionStmtBreak(p0 *ActionStmtLoopControl) any

func (*UnimplementedActionVisitor) VisitActionStmtCall

func (s *UnimplementedActionVisitor) VisitActionStmtCall(p0 *ActionStmtCall) any

func (*UnimplementedActionVisitor) VisitActionStmtDeclaration

func (s *UnimplementedActionVisitor) VisitActionStmtDeclaration(p0 *ActionStmtDeclaration) any

func (*UnimplementedActionVisitor) VisitActionStmtForLoop

func (s *UnimplementedActionVisitor) VisitActionStmtForLoop(p0 *ActionStmtForLoop) any

func (*UnimplementedActionVisitor) VisitActionStmtIf

func (s *UnimplementedActionVisitor) VisitActionStmtIf(p0 *ActionStmtIf) any

func (*UnimplementedActionVisitor) VisitActionStmtReturn

func (s *UnimplementedActionVisitor) VisitActionStmtReturn(p0 *ActionStmtReturn) any

func (*UnimplementedActionVisitor) VisitActionStmtReturnNext

func (s *UnimplementedActionVisitor) VisitActionStmtReturnNext(p0 *ActionStmtReturnNext) any

func (*UnimplementedActionVisitor) VisitActionStmtSQL

func (s *UnimplementedActionVisitor) VisitActionStmtSQL(p0 *ActionStmtSQL) any

func (*UnimplementedActionVisitor) VisitIfThen

func (s *UnimplementedActionVisitor) VisitIfThen(p0 *IfThen) any

func (*UnimplementedActionVisitor) VisitLoopTermRange

func (s *UnimplementedActionVisitor) VisitLoopTermRange(p0 *LoopTermRange) any

func (*UnimplementedActionVisitor) VisitLoopTermSQL

func (s *UnimplementedActionVisitor) VisitLoopTermSQL(p0 *LoopTermSQL) any

type UnimplementedDDLVisitor

type UnimplementedDDLVisitor struct{}

func (*UnimplementedDDLVisitor) VisitAddColumn

func (u *UnimplementedDDLVisitor) VisitAddColumn(p0 *AddColumn) any

func (*UnimplementedDDLVisitor) VisitAddTableConstraint

func (u *UnimplementedDDLVisitor) VisitAddTableConstraint(p0 *AddTableConstraint) any

func (*UnimplementedDDLVisitor) VisitAlterColumnDrop

func (u *UnimplementedDDLVisitor) VisitAlterColumnDrop(p0 *AlterColumnDrop) any

func (*UnimplementedDDLVisitor) VisitAlterColumnSet

func (u *UnimplementedDDLVisitor) VisitAlterColumnSet(p0 *AlterColumnSet) any

func (*UnimplementedDDLVisitor) VisitAlterTableStatement

func (u *UnimplementedDDLVisitor) VisitAlterTableStatement(p0 *AlterTableStatement) any

func (*UnimplementedDDLVisitor) VisitCheckConstraint

func (u *UnimplementedDDLVisitor) VisitCheckConstraint(p0 *CheckConstraint) any

func (*UnimplementedDDLVisitor) VisitColumn

func (u *UnimplementedDDLVisitor) VisitColumn(p0 *Column) any

func (*UnimplementedDDLVisitor) VisitCreateActionStatement

func (u *UnimplementedDDLVisitor) VisitCreateActionStatement(p0 *CreateActionStatement) any

func (*UnimplementedDDLVisitor) VisitCreateIndexStatement

func (u *UnimplementedDDLVisitor) VisitCreateIndexStatement(p0 *CreateIndexStatement) any

func (*UnimplementedDDLVisitor) VisitCreateNamespaceStatement

func (u *UnimplementedDDLVisitor) VisitCreateNamespaceStatement(p0 *CreateNamespaceStatement) any

func (*UnimplementedDDLVisitor) VisitCreateRoleStatement

func (u *UnimplementedDDLVisitor) VisitCreateRoleStatement(p0 *CreateRoleStatement) any

func (*UnimplementedDDLVisitor) VisitCreateTableStatement

func (u *UnimplementedDDLVisitor) VisitCreateTableStatement(p0 *CreateTableStatement) any

func (*UnimplementedDDLVisitor) VisitDefaultConstraint

func (u *UnimplementedDDLVisitor) VisitDefaultConstraint(p0 *DefaultConstraint) any

func (*UnimplementedDDLVisitor) VisitDropActionStatement

func (u *UnimplementedDDLVisitor) VisitDropActionStatement(p0 *DropActionStatement) any

func (*UnimplementedDDLVisitor) VisitDropColumn

func (u *UnimplementedDDLVisitor) VisitDropColumn(p0 *DropColumn) any

func (*UnimplementedDDLVisitor) VisitDropIndexStatement

func (u *UnimplementedDDLVisitor) VisitDropIndexStatement(p0 *DropIndexStatement) any

func (*UnimplementedDDLVisitor) VisitDropNamespaceStatement

func (u *UnimplementedDDLVisitor) VisitDropNamespaceStatement(p0 *DropNamespaceStatement) any

func (*UnimplementedDDLVisitor) VisitDropRoleStatement

func (u *UnimplementedDDLVisitor) VisitDropRoleStatement(p0 *DropRoleStatement) any

func (*UnimplementedDDLVisitor) VisitDropTableConstraint

func (u *UnimplementedDDLVisitor) VisitDropTableConstraint(p0 *DropTableConstraint) any

func (*UnimplementedDDLVisitor) VisitDropTableStatement

func (u *UnimplementedDDLVisitor) VisitDropTableStatement(p0 *DropTableStatement) any

func (*UnimplementedDDLVisitor) VisitForeignKeyOutOfLineConstraint

func (u *UnimplementedDDLVisitor) VisitForeignKeyOutOfLineConstraint(p0 *ForeignKeyOutOfLineConstraint) any

func (*UnimplementedDDLVisitor) VisitForeignKeyReferences

func (u *UnimplementedDDLVisitor) VisitForeignKeyReferences(p0 *ForeignKeyReferences) any

func (*UnimplementedDDLVisitor) VisitGrantOrRevokeStatement

func (u *UnimplementedDDLVisitor) VisitGrantOrRevokeStatement(p0 *GrantOrRevokeStatement) any

func (*UnimplementedDDLVisitor) VisitNotNullConstraint

func (u *UnimplementedDDLVisitor) VisitNotNullConstraint(p0 *NotNullConstraint) any

func (*UnimplementedDDLVisitor) VisitPrimaryKeyInlineConstraint

func (u *UnimplementedDDLVisitor) VisitPrimaryKeyInlineConstraint(p0 *PrimaryKeyInlineConstraint) any

func (*UnimplementedDDLVisitor) VisitPrimaryKeyOutOfLineConstraint

func (u *UnimplementedDDLVisitor) VisitPrimaryKeyOutOfLineConstraint(p0 *PrimaryKeyOutOfLineConstraint) any

func (*UnimplementedDDLVisitor) VisitRenameColumn

func (u *UnimplementedDDLVisitor) VisitRenameColumn(p0 *RenameColumn) any

func (*UnimplementedDDLVisitor) VisitRenameTable

func (u *UnimplementedDDLVisitor) VisitRenameTable(p0 *RenameTable) any

func (*UnimplementedDDLVisitor) VisitUniqueInlineConstraint

func (u *UnimplementedDDLVisitor) VisitUniqueInlineConstraint(p0 *UniqueInlineConstraint) any

func (*UnimplementedDDLVisitor) VisitUniqueOutOfLineConstraint

func (u *UnimplementedDDLVisitor) VisitUniqueOutOfLineConstraint(p0 *UniqueOutOfLineConstraint) any

func (*UnimplementedDDLVisitor) VisitUnuseExtensionStatement

func (u *UnimplementedDDLVisitor) VisitUnuseExtensionStatement(p0 *UnuseExtensionStatement) any

func (*UnimplementedDDLVisitor) VisitUseExtensionStatement

func (u *UnimplementedDDLVisitor) VisitUseExtensionStatement(p0 *UseExtensionStatement) any

type UniqueInlineConstraint

type UniqueInlineConstraint struct {
	Position
}

func (*UniqueInlineConstraint) Accept

func (c *UniqueInlineConstraint) Accept(v Visitor) any

type UniqueOutOfLineConstraint

type UniqueOutOfLineConstraint struct {
	Position
	Columns []string
}

func (*UniqueOutOfLineConstraint) Accept

func (c *UniqueOutOfLineConstraint) Accept(v Visitor) any

func (*UniqueOutOfLineConstraint) LocalColumns

func (c *UniqueOutOfLineConstraint) LocalColumns() []string

type UnuseExtensionStatement

type UnuseExtensionStatement struct {
	Position
	IfExists bool
	Alias    string
}

func (*UnuseExtensionStatement) Accept

func (u *UnuseExtensionStatement) Accept(v Visitor) any

type UpdateSetClause

type UpdateSetClause struct {
	Position
	Column string
	Value  Expression
}

func (*UpdateSetClause) Accept

func (u *UpdateSetClause) Accept(v Visitor) any

type UpdateStatement

type UpdateStatement struct {
	Position
	Table     string
	Alias     string // can be empty
	SetClause []*UpdateSetClause
	From      Table      // can be nil
	Joins     []*Join    // can be nil
	Where     Expression // can be nil
}

func (*UpdateStatement) Accept

func (u *UpdateStatement) Accept(v Visitor) any

type UseExtensionStatement

type UseExtensionStatement struct {
	Position
	IfNotExists bool
	ExtName     string
	Config      []*struct {
		Key   string
		Value Expression
	}
	Alias string
}

func (*UseExtensionStatement) Accept

func (u *UseExtensionStatement) Accept(v Visitor) any

type VariablePrefix

type VariablePrefix string
const (
	VariablePrefixDollar VariablePrefix = "$"
	VariablePrefixAt     VariablePrefix = "@"
)

type Visitor

type Visitor interface {
	ActionVisitor
	DDLVisitor
}

Visitor is an interface for visiting nodes in the parse tree.

type Window

type Window interface {
	Node
	// contains filtered or unexported methods
}

Window is an interface for all window functions. It can either reference an exact window (e.g. OVER (partition by ... order by ...)) or it can reference a window function name (e.g. OVER my_window).

type WindowImpl

type WindowImpl struct {
	Position
	// PartitionBy is the partition by clause.
	PartitionBy []Expression
	// OrderBy is the order by clause.
	OrderBy []*OrderingTerm
}

func (*WindowImpl) Accept

func (w *WindowImpl) Accept(v Visitor) any

type WindowReference

type WindowReference struct {
	Position
	// Name is the name of the window.
	Name string
}

func (*WindowReference) Accept

func (w *WindowReference) Accept(v Visitor) any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳