framework

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AggregateCatalog = map[string][]AggregateFunctionInterface{}

AggregateCatalog contains all of the PostgreSQL aggregate functions.

View Source
var Catalog = map[string][]FunctionInterface{}

Catalog contains all of the PostgreSQL functions.

View Source
var ErrFunctionDoesNotExist = errors.NewKind(`function %s does not exist`)

ErrFunctionDoesNotExist is returned when the function in use cannot be found.

Functions

func AddAssignmentTypeCast added in v0.8.0

func AddAssignmentTypeCast(cast TypeCast) error

AddAssignmentTypeCast registers the given assignment type cast.

func AddExplicitTypeCast added in v0.6.0

func AddExplicitTypeCast(cast TypeCast) error

AddExplicitTypeCast registers the given explicit type cast.

func AddImplicitTypeCast added in v0.6.0

func AddImplicitTypeCast(cast TypeCast) error

AddImplicitTypeCast registers the given implicit type cast.

func FindCommonType added in v0.11.1

func FindCommonType(types []*pgtypes.DoltgresType) (*pgtypes.DoltgresType, error)

FindCommonType returns the common type that given types can convert to. https://www.postgresql.org/docs/15/typeconv-union-case.html

func GetAssignmentCast added in v0.8.0

func GetAssignmentCast(fromType *pgtypes.DoltgresType, toType *pgtypes.DoltgresType) pgtypes.TypeCastFunction

GetAssignmentCast returns the assignment type cast function that will cast the "from" type to the "to" type. Returns nil if such a cast is not valid.

func GetExplicitCast added in v0.6.0

func GetExplicitCast(fromType *pgtypes.DoltgresType, toType *pgtypes.DoltgresType) pgtypes.TypeCastFunction

GetExplicitCast returns the explicit type cast function that will cast the "from" type to the "to" type. Returns nil if such a cast is not valid.

func GetImplicitCast added in v0.6.0

func GetImplicitCast(fromType *pgtypes.DoltgresType, toType *pgtypes.DoltgresType) pgtypes.TypeCastFunction

GetImplicitCast returns the implicit type cast function that will cast the "from" type to the "to" type. Returns nil if such a cast is not valid.

func GetPotentialAssignmentCasts added in v0.8.0

func GetPotentialAssignmentCasts(fromType id.Type) []*pgtypes.DoltgresType

GetPotentialAssignmentCasts returns all registered assignment and implicit type casts from the given type.

func GetPotentialExplicitCasts added in v0.6.0

func GetPotentialExplicitCasts(fromType id.Type) []*pgtypes.DoltgresType

GetPotentialExplicitCasts returns all registered explicit type casts from the given type.

func GetPotentialImplicitCasts added in v0.6.0

func GetPotentialImplicitCasts(fromType id.Type) []*pgtypes.DoltgresType

GetPotentialImplicitCasts returns all registered implicit type casts from the given type.

func Initialize

func Initialize()

Initialize handles the initialization of the catalog by overwriting the built-in GMS functions, since they do not apply to PostgreSQL (and functions of the same name often have different behavior).

func MustAddAssignmentTypeCast added in v0.8.0

func MustAddAssignmentTypeCast(cast TypeCast)

MustAddAssignmentTypeCast registers the given assignment type cast. Panics if an error occurs.

func MustAddExplicitTypeCast added in v0.6.0

func MustAddExplicitTypeCast(cast TypeCast)

MustAddExplicitTypeCast registers the given explicit type cast. Panics if an error occurs.

func MustAddImplicitTypeCast added in v0.6.0

func MustAddImplicitTypeCast(cast TypeCast)

MustAddImplicitTypeCast registers the given implicit type cast. Panics if an error occurs.

func RegisterAggregateFunction added in v0.51.0

func RegisterAggregateFunction(f AggregateFunctionInterface)

RegisterAggregateFunction registers the given function, so that it will be usable from a running server. This should be called from within an init().

func RegisterBinaryFunction

func RegisterBinaryFunction(operator Operator, f Function2)

RegisterBinaryFunction registers the given function, so that it will be usable from a running server. This should only be used for binary functions, which are the underlying functions for binary operators such as addition, subtraction, etc. This should be called from within an init().

func RegisterFunction

func RegisterFunction(f FunctionInterface)

RegisterFunction registers the given function, so that it will be usable from a running server. This should be called from within an init().

func RegisterUnaryFunction

func RegisterUnaryFunction(operator Operator, f Function1)

RegisterUnaryFunction registers the given function, so that it will be usable from a running server. This should only be used for unary functions, which are the underlying functions for unary operators such as negation, etc. This should be called from within an init().

func UnknownLiteralCast added in v0.13.0

func UnknownLiteralCast(ctx *sql.Context, val any, targetType *pgtypes.DoltgresType) (any, error)

UnknownLiteralCast is used when casting from an unknown literal to any type, as unknown literals are treated special in some contexts.

Types

type AggregateFunction added in v0.51.0

type AggregateFunction interface {
	sql.FunctionExpression
	sql.Aggregation
	// contains filtered or unexported methods
}

AggregateFunction is an expression that represents CompiledAggregateFunction

type AggregateFunctionInterface added in v0.51.0

type AggregateFunctionInterface interface {
	FunctionInterface
	// TODO: this maybe needs to take the place of the Callable function
	NewBuffer([]sql.Expression) (sql.AggregationBuffer, error)
}

AggregateFunction is an interface for PostgreSQL aggregate functions

type CFunction added in v0.51.0

type CFunction struct {
	ID                 id.Function
	ReturnType         *pgtypes.DoltgresType
	ParameterTypes     []*pgtypes.DoltgresType
	Variadic           bool
	IsNonDeterministic bool
	Strict             bool
	ExtensionName      extensions.LibraryIdentifier
	ExtensionSymbol    string
}

CFunction is the implementation of functions that host their logic in a shared library.

func (CFunction) GetExpectedParameterCount added in v0.51.0

func (cFunc CFunction) GetExpectedParameterCount() int

GetExpectedParameterCount implements the interface FunctionInterface.

func (CFunction) GetName added in v0.51.0

func (cFunc CFunction) GetName() string

GetName implements the interface FunctionInterface.

func (CFunction) GetParameters added in v0.51.0

func (cFunc CFunction) GetParameters() []*pgtypes.DoltgresType

GetParameters implements the interface FunctionInterface.

func (CFunction) GetReturn added in v0.51.0

func (cFunc CFunction) GetReturn() *pgtypes.DoltgresType

GetReturn implements the interface FunctionInterface.

func (CFunction) InternalID added in v0.51.0

func (cFunc CFunction) InternalID() id.Id

InternalID implements the interface FunctionInterface.

func (CFunction) IsSRF added in v0.51.0

func (cFunc CFunction) IsSRF() bool

ISRF implements the interface FunctionInterface.

func (CFunction) IsStrict added in v0.51.0

func (cFunc CFunction) IsStrict() bool

IsStrict implements the interface FunctionInterface.

func (CFunction) NonDeterministic added in v0.51.0

func (cFunc CFunction) NonDeterministic() bool

NonDeterministic implements the interface FunctionInterface.

func (CFunction) VariadicIndex added in v0.51.0

func (cFunc CFunction) VariadicIndex() int

VariadicIndex implements the interface FunctionInterface.

type CompiledAggregateFunction added in v0.51.0

type CompiledAggregateFunction struct {
	*CompiledFunction
	// contains filtered or unexported fields
}

CompiledAggregateFunction is an expression that represents a fully-analyzed PostgreSQL aggregate function.

func NewCompiledAggregateFunction added in v0.51.0

func NewCompiledAggregateFunction(name string, args []sql.Expression, functions *Overloads, newBuffer NewBufferFn) *CompiledAggregateFunction

NewCompiledAggregateFunction returns a newly compiled function. TODO: newBuffer probably needs to be parameterized in the overloads

func (*CompiledAggregateFunction) DebugString added in v0.51.0

func (c *CompiledAggregateFunction) DebugString() string

func (*CompiledAggregateFunction) Eval added in v0.51.0

func (c *CompiledAggregateFunction) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the interface sql.Expression.

func (*CompiledAggregateFunction) Id added in v0.51.0

Id implements the interface sql.Aggregation.

func (*CompiledAggregateFunction) NewBuffer added in v0.51.0

NewBuffer implements the interface sql.Aggregation.

func (*CompiledAggregateFunction) NewWindowFunction added in v0.51.0

func (c *CompiledAggregateFunction) NewWindowFunction() (sql.WindowFunction, error)

NewWindowFunction implements the interface sql.WindowAdaptableExpression.

func (*CompiledAggregateFunction) SetStatementRunner added in v0.51.0

func (c *CompiledAggregateFunction) SetStatementRunner(ctx *sql.Context, runner sql.StatementRunner) sql.Expression

SetStatementRunner implements the interface analyzer.Interpreter.

func (*CompiledAggregateFunction) Window added in v0.51.0

Window implements the interface sql.WindowAdaptableExpression.

func (*CompiledAggregateFunction) WithChildren added in v0.51.0

func (c *CompiledAggregateFunction) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the interface sql.Expression.

func (*CompiledAggregateFunction) WithId added in v0.51.0

WithId implements the interface sql.Aggregation.

func (*CompiledAggregateFunction) WithWindow added in v0.51.0

WithWindow implements the interface sql.WindowAdaptableExpression.

type CompiledFunction

type CompiledFunction struct {
	Name       string
	Arguments  []sql.Expression
	IsOperator bool
	// contains filtered or unexported fields
}

CompiledFunction is an expression that represents a fully-analyzed PostgreSQL function.

func GetFunction added in v0.8.0

func GetFunction(functionName string, params ...sql.Expression) (*CompiledFunction, bool, error)

GetFunction returns the compiled function with the given name and parameters. Returns false if the function could not be found.

func NewCompiledFunction added in v0.9.0

func NewCompiledFunction(name string, args []sql.Expression, functions *Overloads, isOperator bool) *CompiledFunction

NewCompiledFunction returns a newly compiled function.

func (*CompiledFunction) Children

func (c *CompiledFunction) Children() []sql.Expression

Children implements the interface sql.Expression.

func (*CompiledFunction) Description

func (c *CompiledFunction) Description() string

Description implements the interface sql.Expression.

func (*CompiledFunction) Eval

func (c *CompiledFunction) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the interface sql.Expression.

func (*CompiledFunction) EvalRowIter added in v0.51.0

func (c *CompiledFunction) EvalRowIter(ctx *sql.Context, r sql.Row) (sql.RowIter, error)

EvalRowIter implements sql.RowIterExpression

func (*CompiledFunction) FunctionName

func (c *CompiledFunction) FunctionName() string

FunctionName implements the interface sql.Expression.

func (*CompiledFunction) GetQuickFunction added in v0.16.0

func (c *CompiledFunction) GetQuickFunction() QuickFunction

GetQuickFunction returns the QuickFunction form of this function, if it exists. If one does not exist, then this return nil.

func (*CompiledFunction) IsNonDeterministic added in v0.8.0

func (c *CompiledFunction) IsNonDeterministic() bool

IsNonDeterministic implements the interface sql.NonDeterministicExpression.

func (*CompiledFunction) IsNullable

func (c *CompiledFunction) IsNullable() bool

IsNullable implements the interface sql.Expression.

func (*CompiledFunction) IsSRF added in v0.51.0

func (c *CompiledFunction) IsSRF() bool

IsSRF returns whether this function is a set returning function.

func (*CompiledFunction) IsVariadic added in v0.16.0

func (c *CompiledFunction) IsVariadic() bool

IsVariadic returns whether this function has any variadic parameters.

func (*CompiledFunction) OverloadString

func (c *CompiledFunction) OverloadString(types []*pgtypes.DoltgresType) string

OverloadString returns the name of the function represented by the given overload.

func (*CompiledFunction) Resolved

func (c *CompiledFunction) Resolved() bool

Resolved implements the interface sql.Expression.

func (*CompiledFunction) ReturnsRowIter added in v0.51.0

func (c *CompiledFunction) ReturnsRowIter() bool

ReturnsRowIter implements the interface sql.RowIterExpression

func (*CompiledFunction) SetStatementRunner added in v0.17.0

func (c *CompiledFunction) SetStatementRunner(ctx *sql.Context, runner sql.StatementRunner) sql.Expression

SetStatementRunner implements the interface analyzer.Interpreter.

func (*CompiledFunction) StashedError added in v0.12.0

func (c *CompiledFunction) StashedError() error

StashedError returns the stashed error if one exists. Otherwise, returns nil.

func (*CompiledFunction) String

func (c *CompiledFunction) String() string

String implements the interface sql.Expression.

func (*CompiledFunction) Type

func (c *CompiledFunction) Type() sql.Type

Type implements the interface sql.Expression.

func (*CompiledFunction) WithChildren

func (c *CompiledFunction) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the interface sql.Expression.

type Func1Aggregate added in v0.51.0

type Func1Aggregate struct {
	Function1
	NewAggBuffer func([]sql.Expression) (sql.AggregationBuffer, error)
}

Func1Aggregate is a function that takes one parameter and is an aggregate function.

func (Func1Aggregate) NewBuffer added in v0.51.0

func (f Func1Aggregate) NewBuffer(exprs []sql.Expression) (sql.AggregationBuffer, error)

type Function

type Function interface {
	sql.FunctionExpression
	sql.NonDeterministicExpression
	// contains filtered or unexported methods
}

Function is an expression that represents either a CompiledFunction or a QuickFunction.

type Function0

type Function0 struct {
	Name               string
	Return             *pgtypes.DoltgresType
	IsNonDeterministic bool
	Strict             bool
	SRF                bool
	Callable           func(ctx *sql.Context) (any, error)
}

Function0 is a function that does not take any parameters.

func (Function0) GetExpectedParameterCount

func (f Function0) GetExpectedParameterCount() int

GetExpectedParameterCount implements the FunctionInterface interface.

func (Function0) GetName

func (f Function0) GetName() string

GetName implements the FunctionInterface interface.

func (Function0) GetParameters

func (f Function0) GetParameters() []*pgtypes.DoltgresType

GetParameters implements the FunctionInterface interface.

func (Function0) GetReturn

func (f Function0) GetReturn() *pgtypes.DoltgresType

GetReturn implements the FunctionInterface interface.

func (Function0) InternalID added in v0.16.0

func (f Function0) InternalID() id.Id

InternalID implements the FunctionInterface interface.

func (Function0) IsSRF added in v0.51.0

func (f Function0) IsSRF() bool

IsSRF implements the FunctionInterface interface.

func (Function0) IsStrict added in v0.11.0

func (f Function0) IsStrict() bool

IsStrict implements the FunctionInterface interface.

func (Function0) NonDeterministic added in v0.11.0

func (f Function0) NonDeterministic() bool

NonDeterministic implements the FunctionInterface interface.

func (Function0) VariadicIndex added in v0.11.0

func (f Function0) VariadicIndex() int

type Function1

type Function1 struct {
	Name               string
	Return             *pgtypes.DoltgresType
	Parameters         [1]*pgtypes.DoltgresType
	Variadic           bool
	IsNonDeterministic bool
	Strict             bool
	SRF                bool
	Callable           func(ctx *sql.Context, paramsAndReturn [2]*pgtypes.DoltgresType, val1 any) (any, error)
}

Function1 is a function that takes one parameter. The parameter and return type is passed into the Callable function when the parameter (and possibly return type) is a polymorphic type. The return type is the last type in the array.

func (Function1) GetExpectedParameterCount

func (f Function1) GetExpectedParameterCount() int

GetExpectedParameterCount implements the FunctionInterface interface.

func (Function1) GetName

func (f Function1) GetName() string

GetName implements the FunctionInterface interface.

func (Function1) GetParameters

func (f Function1) GetParameters() []*pgtypes.DoltgresType

GetParameters implements the FunctionInterface interface.

func (Function1) GetReturn

func (f Function1) GetReturn() *pgtypes.DoltgresType

GetReturn implements the FunctionInterface interface.

func (Function1) InternalID added in v0.16.0

func (f Function1) InternalID() id.Id

InternalID implements the FunctionInterface interface.

func (Function1) IsSRF added in v0.51.0

func (f Function1) IsSRF() bool

IsSRF implements the FunctionInterface interface.

func (Function1) IsStrict added in v0.11.0

func (f Function1) IsStrict() bool

IsStrict implements the FunctionInterface interface.

func (Function1) NonDeterministic added in v0.11.0

func (f Function1) NonDeterministic() bool

NonDeterministic implements the FunctionInterface interface.

func (Function1) VariadicIndex added in v0.11.0

func (f Function1) VariadicIndex() int

VariadicIndex implements the FunctionInterface interface.

type Function2

type Function2 struct {
	Name               string
	Return             *pgtypes.DoltgresType
	Parameters         [2]*pgtypes.DoltgresType
	Variadic           bool
	IsNonDeterministic bool
	Strict             bool
	SRF                bool
	Callable           func(ctx *sql.Context, paramsAndReturn [3]*pgtypes.DoltgresType, val1 any, val2 any) (any, error)
}

Function2 is a function that takes two parameters. The parameter and return types are passed into the Callable function when the parameters (and possibly return type) have at least one polymorphic type. The return type is the last type in the array.

func (Function2) GetExpectedParameterCount

func (f Function2) GetExpectedParameterCount() int

GetExpectedParameterCount implements the FunctionInterface interface.

func (Function2) GetName

func (f Function2) GetName() string

GetName implements the FunctionInterface interface.

func (Function2) GetParameters

func (f Function2) GetParameters() []*pgtypes.DoltgresType

GetParameters implements the FunctionInterface interface.

func (Function2) GetReturn

func (f Function2) GetReturn() *pgtypes.DoltgresType

GetReturn implements the FunctionInterface interface.

func (Function2) InternalID added in v0.16.0

func (f Function2) InternalID() id.Id

InternalID implements the FunctionInterface interface.

func (Function2) IsSRF added in v0.51.0

func (f Function2) IsSRF() bool

IsSRF implements the FunctionInterface interface.

func (Function2) IsStrict added in v0.11.0

func (f Function2) IsStrict() bool

IsStrict implements the FunctionInterface interface.

func (Function2) NonDeterministic added in v0.11.0

func (f Function2) NonDeterministic() bool

NonDeterministic implements the FunctionInterface interface.

func (Function2) VariadicIndex added in v0.11.0

func (f Function2) VariadicIndex() int

VariadicIndex implements the FunctionInterface interface.

type Function3

type Function3 struct {
	Name               string
	Return             *pgtypes.DoltgresType
	Parameters         [3]*pgtypes.DoltgresType
	Variadic           bool
	IsNonDeterministic bool
	Strict             bool
	SRF                bool
	Callable           func(ctx *sql.Context, paramsAndReturn [4]*pgtypes.DoltgresType, val1 any, val2 any, val3 any) (any, error)
}

Function3 is a function that takes three parameters. The parameter and return types are passed into the Callable function when the parameters (and possibly return type) have at least one polymorphic type. The return type is the last type in the array.

func (Function3) GetExpectedParameterCount

func (f Function3) GetExpectedParameterCount() int

GetExpectedParameterCount implements the FunctionInterface interface.

func (Function3) GetName

func (f Function3) GetName() string

GetName implements the FunctionInterface interface.

func (Function3) GetParameters

func (f Function3) GetParameters() []*pgtypes.DoltgresType

GetParameters implements the FunctionInterface interface.

func (Function3) GetReturn

func (f Function3) GetReturn() *pgtypes.DoltgresType

GetReturn implements the FunctionInterface interface.

func (Function3) InternalID added in v0.16.0

func (f Function3) InternalID() id.Id

InternalID implements the FunctionInterface interface.

func (Function3) IsSRF added in v0.51.0

func (f Function3) IsSRF() bool

IsSRF implements the FunctionInterface interface.

func (Function3) IsStrict added in v0.11.0

func (f Function3) IsStrict() bool

IsStrict implements the FunctionInterface interface.

func (Function3) NonDeterministic added in v0.11.0

func (f Function3) NonDeterministic() bool

NonDeterministic implements the FunctionInterface interface.

func (Function3) VariadicIndex added in v0.11.0

func (f Function3) VariadicIndex() int

VariadicIndex implements the FunctionInterface interface.

type Function4

type Function4 struct {
	Name               string
	Return             *pgtypes.DoltgresType
	Parameters         [4]*pgtypes.DoltgresType
	Variadic           bool
	IsNonDeterministic bool
	Strict             bool
	SRF                bool
	Callable           func(ctx *sql.Context, paramsAndReturn [5]*pgtypes.DoltgresType, val1 any, val2 any, val3 any, val4 any) (any, error)
}

Function4 is a function that takes four parameters. The parameter and return types are passed into the Callable function when the parameters (and possibly return type) have at least one polymorphic type. The return type is the last type in the array.

func (Function4) GetExpectedParameterCount

func (f Function4) GetExpectedParameterCount() int

GetExpectedParameterCount implements the FunctionInterface interface.

func (Function4) GetName

func (f Function4) GetName() string

GetName implements the FunctionInterface interface.

func (Function4) GetParameters

func (f Function4) GetParameters() []*pgtypes.DoltgresType

GetParameters implements the FunctionInterface interface.

func (Function4) GetReturn

func (f Function4) GetReturn() *pgtypes.DoltgresType

GetReturn implements the FunctionInterface interface.

func (Function4) InternalID added in v0.16.0

func (f Function4) InternalID() id.Id

InternalID implements the FunctionInterface interface.

func (Function4) IsSRF added in v0.51.0

func (f Function4) IsSRF() bool

IsSRF implements the FunctionInterface interface.

func (Function4) IsStrict added in v0.11.0

func (f Function4) IsStrict() bool

IsStrict implements the FunctionInterface interface.

func (Function4) NonDeterministic added in v0.11.0

func (f Function4) NonDeterministic() bool

NonDeterministic implements the FunctionInterface interface.

func (Function4) VariadicIndex added in v0.11.0

func (f Function4) VariadicIndex() int

VariadicIndex implements the FunctionInterface interface.

type FunctionInterface

type FunctionInterface interface {
	// GetName returns the name of the function. The name is case-insensitive, so the casing does not matter.
	GetName() string
	// GetReturn returns the return type.
	GetReturn() *pgtypes.DoltgresType
	// GetParameters returns the parameter types for the function.
	GetParameters() []*pgtypes.DoltgresType
	// VariadicIndex returns the index of the variadic parameter, if it exists, or -1 otherwise
	VariadicIndex() int
	// GetExpectedParameterCount returns the number of parameters that are valid for this function.
	GetExpectedParameterCount() int
	// NonDeterministic returns whether the function is non-deterministic.
	NonDeterministic() bool
	// IsStrict returns whether the function is STRICT, which means if any parameter is NULL, then it returns NULL.
	// Otherwise, if it's not, the NULL input must be handled by user.
	IsStrict() bool
	// IsSRF returns whether the function is set returning function, meaning whether the function returns one or more
	// rows as a result.
	IsSRF() bool
	// InternalID returns the ID associated with this function.
	InternalID() id.Id
	// contains filtered or unexported methods
}

FunctionInterface is an interface for PostgreSQL functions.

type FunctionProvider added in v0.17.0

type FunctionProvider struct{}

FunctionProvider is the special sql.FunctionProvider for Doltgres that allows us to handle functions that are created by users.

func (*FunctionProvider) Function added in v0.17.0

func (fp *FunctionProvider) Function(ctx *sql.Context, name string) (sql.Function, bool)

Function implements the interface sql.FunctionProvider.

type IntermediateFunction

type IntermediateFunction struct {
	Functions    *Overloads
	AllOverloads []Overload
	IsOperator   bool
}

IntermediateFunction is an expression that represents an incomplete PostgreSQL function.

func GetBinaryFunction

func GetBinaryFunction(operator Operator) IntermediateFunction

GetBinaryFunction returns the binary function that matches the given operator.

func GetUnaryFunction

func GetUnaryFunction(operator Operator) IntermediateFunction

GetUnaryFunction returns the unary function that matches the given operator.

func (IntermediateFunction) Compile

func (f IntermediateFunction) Compile(name string, parameters ...sql.Expression) *CompiledFunction

Compile returns a CompiledFunction created from the calling IntermediateFunction. Returns a nil function if it could not be compiled.

type InterpretedFunction added in v0.17.0

type InterpretedFunction struct {
	ID                 id.Function
	ReturnType         *pgtypes.DoltgresType
	ParameterNames     []string
	ParameterTypes     []*pgtypes.DoltgresType
	Variadic           bool
	IsNonDeterministic bool
	Strict             bool
	SRF                bool
	Statements         []plpgsql.InterpreterOperation
}

InterpretedFunction is the implementation of functions created using PL/pgSQL. The created functions are converted to a collection of operations, and an interpreter iterates over those operations to handle the logic.

func (InterpretedFunction) GetExpectedParameterCount added in v0.17.0

func (iFunc InterpretedFunction) GetExpectedParameterCount() int

GetExpectedParameterCount implements the interface FunctionInterface.

func (InterpretedFunction) GetName added in v0.17.0

func (iFunc InterpretedFunction) GetName() string

GetName implements the interface FunctionInterface.

func (InterpretedFunction) GetParameterNames added in v0.17.0

func (iFunc InterpretedFunction) GetParameterNames() []string

GetParameterNames returns the names of all parameters.

func (InterpretedFunction) GetParameters added in v0.17.0

func (iFunc InterpretedFunction) GetParameters() []*pgtypes.DoltgresType

GetParameters implements the interface FunctionInterface.

func (InterpretedFunction) GetReturn added in v0.17.0

func (iFunc InterpretedFunction) GetReturn() *pgtypes.DoltgresType

GetReturn implements the interface FunctionInterface.

func (InterpretedFunction) GetStatements added in v0.17.0

func (iFunc InterpretedFunction) GetStatements() []plpgsql.InterpreterOperation

GetStatements returns the contained statements.

func (InterpretedFunction) InternalID added in v0.17.0

func (iFunc InterpretedFunction) InternalID() id.Id

InternalID implements the interface FunctionInterface.

func (InterpretedFunction) IsSRF added in v0.51.0

func (iFunc InterpretedFunction) IsSRF() bool

IsSRF implements the interface FunctionInterface.

func (InterpretedFunction) IsStrict added in v0.17.0

func (iFunc InterpretedFunction) IsStrict() bool

IsStrict implements the interface FunctionInterface.

func (InterpretedFunction) NonDeterministic added in v0.17.0

func (iFunc InterpretedFunction) NonDeterministic() bool

NonDeterministic implements the interface FunctionInterface.

func (InterpretedFunction) QueryMultiReturn added in v0.17.0

func (InterpretedFunction) QueryMultiReturn(ctx *sql.Context, stack plpgsql.InterpreterStack, stmt string, bindings []string) (rows []sql.Row, err error)

QueryMultiReturn handles queries that may return multiple values over multiple rows.

func (InterpretedFunction) QuerySingleReturn added in v0.17.0

func (InterpretedFunction) QuerySingleReturn(ctx *sql.Context, stack plpgsql.InterpreterStack, stmt string, targetType *pgtypes.DoltgresType, bindings []string) (val any, err error)

QuerySingleReturn handles queries that are supposed to return a single value.

func (InterpretedFunction) VariadicIndex added in v0.17.0

func (iFunc InterpretedFunction) VariadicIndex() int

VariadicIndex implements the interface FunctionInterface.

type NewBufferFn added in v0.51.0

type NewBufferFn func([]sql.Expression) (sql.AggregationBuffer, error)

type Operator

type Operator byte

Operator is a unary or binary operator.

const (
	Operator_BinaryPlus                Operator = iota // +
	Operator_BinaryMinus                               // -
	Operator_BinaryMultiply                            // *
	Operator_BinaryDivide                              // /
	Operator_BinaryMod                                 // %
	Operator_BinaryShiftLeft                           // <<
	Operator_BinaryShiftRight                          // >>
	Operator_BinaryLessThan                            // <
	Operator_BinaryGreaterThan                         // >
	Operator_BinaryLessOrEqual                         // <=
	Operator_BinaryGreaterOrEqual                      // >=
	Operator_BinaryEqual                               // =
	Operator_BinaryNotEqual                            // <> or != (they're equivalent in all cases)
	Operator_BinaryBitAnd                              // &
	Operator_BinaryBitOr                               // |
	Operator_BinaryBitXor                              // ^
	Operator_BinaryConcatenate                         // ||
	Operator_BinaryJSONExtractJson                     // ->
	Operator_BinaryJSONExtractText                     // ->>
	Operator_BinaryJSONExtractPathJson                 // #>
	Operator_BinaryJSONExtractPathText                 // #>>
	Operator_BinaryJSONContainsRight                   // @>
	Operator_BinaryJSONContainsLeft                    // <@
	Operator_BinaryJSONTopLevel                        // ?
	Operator_BinaryJSONTopLevelAny                     // ?|
	Operator_BinaryJSONTopLevelAll                     // ?&
	Operator_UnaryPlus                                 // +
	Operator_UnaryMinus                                // -
)

func GetOperatorFromString added in v0.11.0

func GetOperatorFromString(op string) (Operator, error)

GetOperatorFromString returns the binary operator for the given subOperator.

func (Operator) IsBinary

func (o Operator) IsBinary() bool

IsBinary returns whether the operator is a binary operator.

func (Operator) IsUnary

func (o Operator) IsUnary() bool

IsUnary returns whether the operator is a unary operator.

func (Operator) String

func (o Operator) String() string

String returns the string form of the operator.

type Overload added in v0.11.0

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

Overload is a single overload of a given function, used during evaluation to match the arguments provided to a particular overload.

type Overloads added in v0.11.0

type Overloads struct {
	// ByParamType contains all overloads for the function with this name, indexed by the key of the parameter types.
	ByParamType map[string]FunctionInterface
	// AllOverloads contains all overloads for the function with this name
	AllOverloads []FunctionInterface
}

Overloads is the collection of all overloads for a given function name.

func NewOverloads added in v0.11.0

func NewOverloads() *Overloads

NewOverloads creates a new empty overload collection.

func (*Overloads) Add added in v0.11.0

func (o *Overloads) Add(function FunctionInterface) error

Add adds the given function to the overload collection. Returns an error if the there's a problem with the function's declaration.

func (*Overloads) ExactMatchForTypes added in v0.11.0

func (o *Overloads) ExactMatchForTypes(types ...*pgtypes.DoltgresType) (FunctionInterface, bool)

ExactMatchForTypes returns the function that exactly matches the given parameter types, or nil if no overload with those types exists.

type QuickFunction added in v0.16.0

type QuickFunction interface {
	Function
	sql.RowIterExpression
	// CallVariadic is the variadic form of the Call function that is specific to each implementation of QuickFunction.
	// The implementation will not verify that the correct number of arguments have been passed.
	CallVariadic(ctx *sql.Context, args ...any) (interface{}, error)
	// ResolvedTypes returns the types that were resolved with this function.
	ResolvedTypes() []*pgtypes.DoltgresType
	// WithResolvedTypes returns a new QuickFunction with the replaced resolved types. The implementation will not
	// verify that the new types are correct in any way. This returns a QuickFunction, however it's typed as "any" due
	// to potential import cycles.
	WithResolvedTypes(newTypes []*pgtypes.DoltgresType) any
}

QuickFunction represents an optimized function expression that has specific criteria in order to streamline evaluation. This will only apply to very specific functions that are generally performance-critical.

type QuickFunction1 added in v0.16.0

type QuickFunction1 struct {
	Name     string
	Argument sql.Expression
	IsStrict bool
	IsSRF    bool
	// contains filtered or unexported fields
}

QuickFunction1 is an implementation of QuickFunction that handles a single parameter.

func (*QuickFunction1) Call added in v0.16.0

func (q *QuickFunction1) Call(ctx *sql.Context, arg0 any) (interface{}, error)

Call directly calls the underlying function with the given arguments. This does not perform any form of NULL checking as it is assumed that it was done prior to this call. It also does not validate any types. This exists purely for performance, when we can guarantee that the input is always valid and well-formed.

func (*QuickFunction1) CallVariadic added in v0.16.0

func (q *QuickFunction1) CallVariadic(ctx *sql.Context, args ...any) (interface{}, error)

CallVariadic implements the interface QuickFunction.

func (*QuickFunction1) Children added in v0.16.0

func (q *QuickFunction1) Children() []sql.Expression

Children implements the interface sql.Expression.

func (*QuickFunction1) Description added in v0.16.0

func (q *QuickFunction1) Description() string

Description implements the interface sql.Expression.

func (*QuickFunction1) Eval added in v0.16.0

func (q *QuickFunction1) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the interface sql.Expression.

func (*QuickFunction1) EvalRowIter added in v0.51.0

func (q *QuickFunction1) EvalRowIter(ctx *sql.Context, r sql.Row) (sql.RowIter, error)

EvalRowIter implements the interface sql.RowIterExpression.

func (*QuickFunction1) FunctionName added in v0.16.0

func (q *QuickFunction1) FunctionName() string

FunctionName implements the interface sql.Expression.

func (*QuickFunction1) IsNonDeterministic added in v0.16.0

func (q *QuickFunction1) IsNonDeterministic() bool

IsNonDeterministic implements the interface sql.NonDeterministicExpression.

func (*QuickFunction1) IsNullable added in v0.16.0

func (q *QuickFunction1) IsNullable() bool

IsNullable implements the interface sql.Expression.

func (*QuickFunction1) Resolved added in v0.16.0

func (q *QuickFunction1) Resolved() bool

Resolved implements the interface sql.Expression.

func (*QuickFunction1) ResolvedTypes added in v0.16.0

func (q *QuickFunction1) ResolvedTypes() []*pgtypes.DoltgresType

ResolvedTypes implements the interface QuickFunction.

func (*QuickFunction1) ReturnsRowIter added in v0.51.0

func (q *QuickFunction1) ReturnsRowIter() bool

ReturnsRowIter implements the interface sql.RowIterExpression.

func (*QuickFunction1) String added in v0.16.0

func (q *QuickFunction1) String() string

String implements the interface sql.Expression.

func (*QuickFunction1) Type added in v0.16.0

func (q *QuickFunction1) Type() sql.Type

Type implements the interface sql.Expression.

func (*QuickFunction1) WithChildren added in v0.16.0

func (q *QuickFunction1) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the interface sql.Expression.

func (*QuickFunction1) WithResolvedTypes added in v0.16.0

func (q *QuickFunction1) WithResolvedTypes(newTypes []*pgtypes.DoltgresType) any

WithResolvedTypes implements the interface QuickFunction.

type QuickFunction2 added in v0.16.0

type QuickFunction2 struct {
	Name      string
	Arguments [2]sql.Expression
	IsStrict  bool
	IsSRF     bool
	// contains filtered or unexported fields
}

QuickFunction2 is an implementation of QuickFunction that handles two parameters.

func (*QuickFunction2) Call added in v0.16.0

func (q *QuickFunction2) Call(ctx *sql.Context, arg0 any, arg1 any) (interface{}, error)

Call directly calls the underlying function with the given arguments. This does not perform any form of NULL checking as it is assumed that it was done prior to this call. It also does not validate any types. This exists purely for performance, when we can guarantee that the input is always valid and well-formed.

func (*QuickFunction2) CallVariadic added in v0.16.0

func (q *QuickFunction2) CallVariadic(ctx *sql.Context, args ...any) (interface{}, error)

CallVariadic implements the interface QuickFunction.

func (*QuickFunction2) Children added in v0.16.0

func (q *QuickFunction2) Children() []sql.Expression

Children implements the interface sql.Expression.

func (*QuickFunction2) Description added in v0.16.0

func (q *QuickFunction2) Description() string

Description implements the interface sql.Expression.

func (*QuickFunction2) Eval added in v0.16.0

func (q *QuickFunction2) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the interface sql.Expression.

func (*QuickFunction2) EvalRowIter added in v0.51.0

func (q *QuickFunction2) EvalRowIter(ctx *sql.Context, r sql.Row) (sql.RowIter, error)

EvalRowIter implements the interface sql.RowIterExpression.

func (*QuickFunction2) FunctionName added in v0.16.0

func (q *QuickFunction2) FunctionName() string

FunctionName implements the interface sql.Expression.

func (*QuickFunction2) IsNonDeterministic added in v0.16.0

func (q *QuickFunction2) IsNonDeterministic() bool

IsNonDeterministic implements the interface sql.NonDeterministicExpression.

func (*QuickFunction2) IsNullable added in v0.16.0

func (q *QuickFunction2) IsNullable() bool

IsNullable implements the interface sql.Expression.

func (*QuickFunction2) Resolved added in v0.16.0

func (q *QuickFunction2) Resolved() bool

Resolved implements the interface sql.Expression.

func (*QuickFunction2) ResolvedTypes added in v0.16.0

func (q *QuickFunction2) ResolvedTypes() []*pgtypes.DoltgresType

ResolvedTypes implements the interface QuickFunction.

func (*QuickFunction2) ReturnsRowIter added in v0.51.0

func (q *QuickFunction2) ReturnsRowIter() bool

ReturnsRowIter implements the interface sql.RowIterExpression.

func (*QuickFunction2) String added in v0.16.0

func (q *QuickFunction2) String() string

String implements the interface sql.Expression.

func (*QuickFunction2) Type added in v0.16.0

func (q *QuickFunction2) Type() sql.Type

Type implements the interface sql.Expression.

func (*QuickFunction2) WithChildren added in v0.16.0

func (q *QuickFunction2) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the interface sql.Expression.

func (*QuickFunction2) WithResolvedTypes added in v0.16.0

func (q *QuickFunction2) WithResolvedTypes(newTypes []*pgtypes.DoltgresType) any

WithResolvedTypes implements the interface QuickFunction.

type QuickFunction3 added in v0.16.0

type QuickFunction3 struct {
	Name      string
	Arguments [3]sql.Expression
	IsStrict  bool
	IsSRF     bool
	// contains filtered or unexported fields
}

QuickFunction3 is an implementation of QuickFunction that handles three parameters.

func (*QuickFunction3) Call added in v0.16.0

func (q *QuickFunction3) Call(ctx *sql.Context, arg0 any, arg1 any, arg2 any) (interface{}, error)

Call directly calls the underlying function with the given arguments. This does not perform any form of NULL checking as it is assumed that it was done prior to this call. It also does not validate any types. This exists purely for performance, when we can guarantee that the input is always valid and well-formed.

func (*QuickFunction3) CallVariadic added in v0.16.0

func (q *QuickFunction3) CallVariadic(ctx *sql.Context, args ...any) (interface{}, error)

CallVariadic implements the interface QuickFunction.

func (*QuickFunction3) Children added in v0.16.0

func (q *QuickFunction3) Children() []sql.Expression

Children implements the interface sql.Expression.

func (*QuickFunction3) Description added in v0.16.0

func (q *QuickFunction3) Description() string

Description implements the interface sql.Expression.

func (*QuickFunction3) Eval added in v0.16.0

func (q *QuickFunction3) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)

Eval implements the interface sql.Expression.

func (*QuickFunction3) EvalRowIter added in v0.51.0

func (q *QuickFunction3) EvalRowIter(ctx *sql.Context, r sql.Row) (sql.RowIter, error)

EvalRowIter implements the interface sql.RowIterExpression.

func (*QuickFunction3) FunctionName added in v0.16.0

func (q *QuickFunction3) FunctionName() string

FunctionName implements the interface sql.Expression.

func (*QuickFunction3) IsNonDeterministic added in v0.16.0

func (q *QuickFunction3) IsNonDeterministic() bool

IsNonDeterministic implements the interface sql.NonDeterministicExpression.

func (*QuickFunction3) IsNullable added in v0.16.0

func (q *QuickFunction3) IsNullable() bool

IsNullable implements the interface sql.Expression.

func (*QuickFunction3) Resolved added in v0.16.0

func (q *QuickFunction3) Resolved() bool

Resolved implements the interface sql.Expression.

func (*QuickFunction3) ResolvedTypes added in v0.16.0

func (q *QuickFunction3) ResolvedTypes() []*pgtypes.DoltgresType

ResolvedTypes implements the interface QuickFunction.

func (*QuickFunction3) ReturnsRowIter added in v0.51.0

func (q *QuickFunction3) ReturnsRowIter() bool

ReturnsRowIter implements the interface sql.RowIterExpression.

func (*QuickFunction3) String added in v0.16.0

func (q *QuickFunction3) String() string

String implements the interface sql.Expression.

func (*QuickFunction3) Type added in v0.16.0

func (q *QuickFunction3) Type() sql.Type

Type implements the interface sql.Expression.

func (*QuickFunction3) WithChildren added in v0.16.0

func (q *QuickFunction3) WithChildren(children ...sql.Expression) (sql.Expression, error)

WithChildren implements the interface sql.Expression.

func (*QuickFunction3) WithResolvedTypes added in v0.16.0

func (q *QuickFunction3) WithResolvedTypes(newTypes []*pgtypes.DoltgresType) any

WithResolvedTypes implements the interface QuickFunction.

type TypeCast

type TypeCast struct {
	FromType *pgtypes.DoltgresType
	ToType   *pgtypes.DoltgresType
	Function pgtypes.TypeCastFunction
}

TypeCast is used to cast from one type to another.

Jump to

Keyboard shortcuts

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