Documentation
¶
Index ¶
- Variables
- type CompiledFunction
- func (c *CompiledFunction) Children() []sql.Expression
- func (c *CompiledFunction) Description() string
- func (c *CompiledFunction) Eval(ctx *sql.Context, row sql.Row) (interface{}, error)
- func (c *CompiledFunction) FunctionName() string
- func (c *CompiledFunction) IsNullable() bool
- func (c *CompiledFunction) OverloadString(types []IntermediateParameter) string
- func (c *CompiledFunction) Resolved() bool
- func (c *CompiledFunction) String() string
- func (c *CompiledFunction) Type() sql.Type
- func (c *CompiledFunction) WithChildren(children ...sql.Expression) (sql.Expression, error)
- type FloatType
- type Function
- type IntegerType
- type IntermediateParameter
- type NumericType
- type OverloadDeduction
- type ParameterType
- type Source
- type StringType
- type TimestampType
Constants ¶
This section is empty.
Variables ¶
var Catalog = []Function{
abs,
acos,
acosd,
acosh,
ascii,
asin,
asind,
asinh,
atan,
atan2,
atan2d,
atand,
atanh,
bit_length,
btrim,
cbrt,
ceil,
ceiling,
char_length,
character_length,
chr,
cos,
cosd,
cosh,
cot,
cotd,
degrees,
div,
exp,
factorial,
floor,
gcd,
initcap,
lcm,
left,
length,
ln,
log,
log10,
lower,
lpad,
ltrim,
md5,
min_scale,
mod,
octet_length,
pi,
power,
radians,
random,
repeat,
replace,
reverse,
right,
round,
rpad,
rtrim,
scale,
sign,
sin,
sind,
sinh,
split_part,
sqrt,
strpos,
substr,
tan,
tand,
tanh,
to_hex,
trim_scale,
trunc,
upper,
width_bucket,
}
Catalog contains all of the PostgreSQL functions. If a new function is added, make sure to add it to the catalog here.
Functions ¶
This section is empty.
Types ¶
type CompiledFunction ¶
type CompiledFunction struct {
Name string
Parameters []sql.Expression
Functions *OverloadDeduction
}
CompiledFunction is an expression that represents a fully-analyzed PostgreSQL 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) FunctionName ¶
func (c *CompiledFunction) FunctionName() string
FunctionName implements the interface sql.Expression.
func (*CompiledFunction) IsNullable ¶
func (c *CompiledFunction) IsNullable() bool
IsNullable implements the interface sql.Expression.
func (*CompiledFunction) OverloadString ¶
func (c *CompiledFunction) OverloadString(types []IntermediateParameter) 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) 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 FloatType ¶
type FloatType struct {
Value float64
IsNull bool
OriginalType ParameterType
Source Source
}
FloatType is a floating point type (float32 is upcast to float64).
type Function ¶
Function is a name, along with a collection of functions, that represent a single PostgreSQL function with all of its overloads.
type IntegerType ¶
type IntegerType struct {
Value int64
IsNull bool
OriginalType ParameterType
Source Source
}
IntegerType is an integer type (all integer types are upcast to int64).
type IntermediateParameter ¶
type IntermediateParameter struct {
Value interface{}
IsNull bool
OriginalType ParameterType
CurrentType ParameterType
Source Source
}
IntermediateParameter is a parameter before it has been finalized.
func (IntermediateParameter) ToValue ¶
func (ip IntermediateParameter) ToValue() reflect.Value
ToValue converts the intermediate parameter into a concrete parameter type (IntegerType, FloatType, etc.) and returns it as a reflect.Value, which may be passed to the matched function.
type NumericType ¶
type NumericType struct {
Value float64 //TODO: should be decimal, but our engine support isn't quite there yet
IsNull bool
OriginalType ParameterType
Source Source
}
NumericType is a decimal type (all integer and float types are upcast to decimal).
type OverloadDeduction ¶
type OverloadDeduction struct {
Function reflect.Value
ReturnSqlType sql.Type
ReturnValType ParameterType
Parameter [ParameterType_Length]*OverloadDeduction
}
OverloadDeduction handles resolving which function to call by iterating over the parameter expressions. This also handles casting between types if an exact function match is not found.
func (*OverloadDeduction) Resolve ¶
func (overload *OverloadDeduction) Resolve(parameters []IntermediateParameter) (*OverloadDeduction, error)
Resolve returns an overload that either matches the given parameters exactly, or is a viable match after casting. This will modify the parameter slice in-place. Returns a nil OverloadDeduction if a viable match is not found.
func (*OverloadDeduction) ResolveByType ¶
func (overload *OverloadDeduction) ResolveByType(originalTypes []ParameterType) (*OverloadDeduction, []ParameterType)
ResolveByType returns the best matching overload for the given types. The returned types represent the actual types used by the overload, which may differ from the calling types. It is up to the caller to cast the parameters to match the types expected by the returned overload. Returns a nil OverloadDeduction if a viable match is not found.
type ParameterType ¶
type ParameterType uint8
ParameterType represents the type of a parameter.
const ( ParameterType_Null ParameterType = iota // The parameter is a NULL value, and is therefore typeless ParameterType_Integer // The parameter is an IntegerType type ParameterType_Float // The parameter is a FloatType type ParameterType_Numeric // The parameter is a NumericType type ParameterType_String // The parameter is a StringType type ParameterType_Timestamp // The parameter is a TimestampType type ParameterType_Length // The number of parameters. This should always be last in the enum declaration. )
func ParameterTypeFromReflection ¶
ParameterTypeFromReflection returns the ParameterType and equivalent sql.Type from the given reflection type. If the given type does not match a ParameterType, then this returns false.
func (ParameterType) PotentialCasts ¶
func (pt ParameterType) PotentialCasts() []ParameterType
PotentialCasts returns all potential casts for the current type. For example, an IntegerType may be cast to a FloatType. Casts may be bidirectional, as a StringType may cast to an IntegerType, and an IntegerType may cast to a StringType.
func (ParameterType) String ¶
func (pt ParameterType) String() string
PotentialCasts returns all potential casts for the current type. For example, an IntegerType may be cast to a FloatType. Casts may be bidirectional, as a StringType may cast to an IntegerType, and an IntegerType may cast to a StringType.
type Source ¶
type Source uint8
Source defines what kind of expression generated the given value, as some functions are context-dependent, and we need to approximate the context.
type StringType ¶
type StringType struct {
Value string
IsNull bool
OriginalType ParameterType
Source Source
}
StringType is a string type.
type TimestampType ¶
type TimestampType struct {
Value time.Time
IsNull bool
OriginalType ParameterType
Source Source
}
TimestampType is a timestamp type.
Source Files
¶
- abs.go
- acos.go
- acosd.go
- acosh.go
- ascii.go
- asin.go
- asind.go
- asinh.go
- atan.go
- atan2.go
- atan2d.go
- atand.go
- atanh.go
- bit_length.go
- btrim.go
- cbrt.go
- ceil.go
- char_length.go
- chr.go
- cos.go
- cosd.go
- cosh.go
- cot.go
- cotd.go
- degrees.go
- div.go
- exp.go
- factorial.go
- floor.go
- gcd.go
- initcap.go
- lcm.go
- left.go
- length.go
- ln.go
- log.go
- log10.go
- lower.go
- lpad.go
- ltrim.go
- md5.go
- min_scale.go
- mod.go
- octet_length.go
- pi.go
- power.go
- radians.go
- random.go
- repeat.go
- replace.go
- reverse.go
- right.go
- round.go
- rpad.go
- rtrim.go
- scale.go
- sign.go
- sin.go
- sind.go
- sinh.go
- split_part.go
- sqrt.go
- strpos.go
- substr.go
- tan.go
- tand.go
- tanh.go
- to_hex.go
- trim_scale.go
- trunc.go
- upper.go
- width_bucket.go
- zinternal_catalog.go
- zinternal_compiled_function.go
- zinternal_overload_deduction.go
- zinternal_parameters.go
- zinternal_source.go