cockroach: github.com/cockroachdb/cockroach/pkg/sql/sem/builtins Index | Files

package builtins

import "github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"

Index

Package Files

aggregate_builtins.go all_builtins.go builtins.go generator_builtins.go pg_builtins.go window_builtins.go window_frame_builtins.go

Constants

const AnyNotNull = "any_not_null"

AnyNotNull is the name of the aggregate returned by NewAnyNotNullAggregate.

const NodeIDBits = 15

NodeIDBits is the number of bits stored in the lower portion of GenerateUniqueInt.

Variables

var (
    // DatEncodingUTFId is the encoding ID for our only supported database
    // encoding, UTF8.
    DatEncodingUTFId = tree.NewDInt(6)
    // DatEncodingEnUTF8 is the encoding name for our only supported database
    // encoding, UTF8.
    DatEncodingEnUTF8 = tree.NewDString("en_US.utf8")
)

http://doxygen.postgresql.org/pg__wchar_8h.html#a22e0c8b9f59f6e226a5968620b4bb6a9aac3b065b882d3231ba59297524da2f23

var AllAggregateBuiltinNames []string

AllAggregateBuiltinNames is an array containing the subset of AllBuiltinNames that corresponds to aggregate functions.

var AllBuiltinNames []string

AllBuiltinNames is an array containing all the built-in function names, sorted in alphabetical order. This can be used for a deterministic walk through the Builtins map.

var AllWindowBuiltinNames []string

AllWindowBuiltinNames is an array containing the subset of AllBuiltinNames that corresponds to window functions.

var EvalFollowerReadOffset func(clusterID uuid.UUID, _ *cluster.Settings) (time.Duration, error)

EvalFollowerReadOffset is a function used often with AS OF SYSTEM TIME queries to determine the appropriate offset from now which is likely to be safe for follower reads. It is injected by followerreadsccl. An error may be returned if an enterprise license is not installed.

func CleanEncodingName Uses

func CleanEncodingName(s string) string

CleanEncodingName sanitizes the string meant to represent a recognized encoding. This ignores any non-alphanumeric character.

See function clean_encoding_name() in postgres' sources in backend/utils/mb/encnames.c.

func EmptyGenerator Uses

func EmptyGenerator() tree.ValueGenerator

EmptyGenerator returns a new, empty generator. Used when a SRF evaluates to NULL.

func GenerateUniqueID Uses

func GenerateUniqueID(nodeID int32, timestamp uint64) tree.DInt

GenerateUniqueID encapsulates the logic to generate a unique number from a nodeID and timestamp.

func GenerateUniqueInt Uses

func GenerateUniqueInt(nodeID roachpb.NodeID) tree.DInt

GenerateUniqueInt creates a unique int composed of the current time at a 10-microsecond granularity and the node-id. The node-id is stored in the lower 15 bits of the returned value and the timestamp is stored in the upper 48 bits. The top-bit is left empty so that negative values are not returned. The 48-bit timestamp field provides for 89 years of timestamps. We use a custom epoch (Jan 1, 2015) in order to utilize the entire timestamp range.

Note that GenerateUniqueInt() imposes a limit on node IDs while generateUniqueBytes() does not.

TODO(pmattis): Do we have to worry about persisting the milliseconds value periodically to avoid the clock ever going backwards (e.g. due to NTP adjustment)?

func GetBuiltinProperties Uses

func GetBuiltinProperties(name string) (*tree.FunctionProperties, []tree.Overload)

GetBuiltinProperties provides low-level access to a built-in function's properties. For a better, semantic-rich interface consider using tree.FunctionDefinition instead, and resolve function names via ResolvableFunctionReference.Resolve().

func NewAggregateWindowFunc Uses

func NewAggregateWindowFunc(
    aggConstructor func(*tree.EvalContext, tree.Datums) tree.AggregateFunc,
) func(*tree.EvalContext) tree.WindowFunc

NewAggregateWindowFunc creates a constructor of aggregateWindowFunc with agg initialized by provided aggConstructor.

func NewAnyNotNullAggregate Uses

func NewAnyNotNullAggregate(*tree.EvalContext, tree.Datums) tree.AggregateFunc

NewAnyNotNullAggregate returns an aggregate function that returns an arbitrary not-NULL value passed to Add (or NULL if no such value). This is particularly useful for "passing through" values for columns which we know are constant within any aggregation group (for example, the grouping columns themselves).

Note that NULL values do not affect the result of the aggregation; this is important in a few different contexts:

- in distributed multi-stage aggregations, we can have a local stage with
  multiple (parallel) instances feeding into a final stage. If some of the
  instances see no rows, they emit a NULL into the final stage which needs
  to be ignored.

- for query optimization, when moving aggregations across left joins (which
  add NULL values).

func PGIOBuiltinPrefix Uses

func PGIOBuiltinPrefix(typ *types.T) string

PGIOBuiltinPrefix returns the string prefix to a type's IO functions. This is either the type's postgres display name or the type's postgres display name plus an underscore, depending on the type.

func ShouldReset Uses

func ShouldReset(w tree.WindowFunc)

ShouldReset sets shouldReset to true if w is framableAggregateWindowFunc.

type MaxAggregate Uses

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

MaxAggregate keeps track of the largest value passed to Add.

func (*MaxAggregate) Add Uses

func (a *MaxAggregate) Add(ctx context.Context, datum tree.Datum, _ ...tree.Datum) error

Add sets the max to the larger of the current max or the passed datum.

func (*MaxAggregate) Close Uses

func (a *MaxAggregate) Close(ctx context.Context)

Close is part of the tree.AggregateFunc interface.

func (*MaxAggregate) Reset Uses

func (a *MaxAggregate) Reset(ctx context.Context)

Reset implements tree.AggregateFunc interface.

func (*MaxAggregate) Result Uses

func (a *MaxAggregate) Result() (tree.Datum, error)

Result returns the largest value passed to Add.

func (*MaxAggregate) Size Uses

func (a *MaxAggregate) Size() int64

Size is part of the tree.AggregateFunc interface.

type MinAggregate Uses

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

MinAggregate keeps track of the smallest value passed to Add.

func (*MinAggregate) Add Uses

func (a *MinAggregate) Add(ctx context.Context, datum tree.Datum, _ ...tree.Datum) error

Add sets the min to the smaller of the current min or the passed datum.

func (*MinAggregate) Close Uses

func (a *MinAggregate) Close(ctx context.Context)

Close is part of the tree.AggregateFunc interface.

func (*MinAggregate) Reset Uses

func (a *MinAggregate) Reset(context.Context)

Reset implements tree.AggregateFunc interface.

func (*MinAggregate) Result Uses

func (a *MinAggregate) Result() (tree.Datum, error)

Result returns the smallest value passed to Add.

func (*MinAggregate) Size Uses

func (a *MinAggregate) Size() int64

Size is part of the tree.AggregateFunc interface.

Package builtins imports 53 packages (graph) and is imported by 22 packages. Updated 2019-09-14. Refresh now. Tools for package owners.