pub trait Aggregate where
    Self: Sized
{ type State; type Args; type OrderedSetArgs; type Finalize; type MovingState;
Show 9 associated constants and 10 methods const NAME: &'static str; const ORDERED_SET: bool; const PARALLEL: Option<ParallelOption>; const FINALIZE_MODIFY: Option<FinalizeModify>; const MOVING_FINALIZE_MODIFY: Option<FinalizeModify>; const INITIAL_CONDITION: Option<&'static str>; const SORT_OPERATOR: Option<&'static str>; const MOVING_INITIAL_CONDITION: Option<&'static str>; const HYPOTHETICAL: bool; fn state(
        current: Self::State,
        v: Self::Args,
        fcinfo: FunctionCallInfo
    ) -> Self::State;
fn finalize(
        current: Self::State,
        direct_args: Self::OrderedSetArgs,
        fcinfo: FunctionCallInfo
    ) -> Self::Finalize;
fn combine(
        current: Self::State,
        _other: Self::State,
        fcinfo: FunctionCallInfo
    ) -> Self::State;
fn serial(current: Self::State, fcinfo: FunctionCallInfo) -> Vec<u8>Notable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
    A: Allocator
;
fn deserial(
        current: Self::State,
        _buf: Vec<u8>,
        _internal: PgBox<Self::State>,
        fcinfo: FunctionCallInfo
    ) -> PgBox<Self::State>;
fn moving_state(
        _mstate: Self::MovingState,
        _v: Self::Args,
        fcinfo: FunctionCallInfo
    ) -> Self::MovingState;
fn moving_state_inverse(
        _mstate: Self::MovingState,
        _v: Self::Args,
        fcinfo: FunctionCallInfo
    ) -> Self::MovingState;
fn moving_finalize(
        _mstate: Self::MovingState,
        direct_args: Self::OrderedSetArgs,
        fcinfo: FunctionCallInfo
    ) -> Self::Finalize; unsafe fn memory_context(fcinfo: FunctionCallInfo) -> Option<MemoryContext>Notable traits for Option<L>impl<L, S> Layer<S> for Option<L> where
    L: Layer<S>,
    S: Subscriber
{ ... }
fn in_memory_context<R, F: FnOnce(&mut PgMemoryContexts) -> R + UnwindSafe + RefUnwindSafe>(
        fcinfo: FunctionCallInfo,
        f: F
    ) -> R { ... }
}
Expand description

Aggregate implementation trait.

When decorated with #[pgx_macros::pg_aggregate], enables the generation of CREATE AGGREGATE SQL.

The #[pgx_macros::pg_aggregate] will automatically fill fields marked optional with stubs.

Associated Types

The type of the return value on state and combine functions.

For an aggregate type which does not have a PgVarlenaInOutFuncs implementation, this can be left out, or set to it’s default, Self.

For an aggregate type which does have a PgVarlenaInOutFuncs implementation, this should be set to PgVarlena<Self>.

Other types are supported as well, this can be useful if multiple aggregates share a state.

The type of the argument(s).

For a single argument, provide the type directly.

For multiple arguments, provide a tuple.

Use pgx::name!() to set the SQL name of the argument.

If the final argument is to be variadic, use pgx::variadic. When used with pgx::name!(), it must be used inside the pgx::name!() macro.

The types of the direct argument(s) to an ordered-set aggregate’s finalize.

Only effective if ORDERED_SET is true.

For a single argument, provide the type directly.

For multiple arguments, provide a tuple.

For no arguments, don’t set this, or set it to () (the default).

pgx does not support argname as it is only used for documentation purposes.

If the final argument is to be variadic, use pgx::Variadic.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Associated Constants

The name of the aggregate. (eg. What you’d pass to SELECT agg(col) FROM tab.)

Set to true if this is an ordered set aggregate.

If set, the OrderedSetArgs associated type becomes effective, this allows for direct arguments to the finalize function.

See https://www.postgresql.org/docs/current/xaggr.html#XAGGR-ORDERED-SET-AGGREGATES for more information.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Optional: This const can be skipped, #[pg_aggregate] will create a stub.

Required methods

The OrderedSetArgs is () unless ORDERED_SET is true and OrderedSetArgs is configured.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

The OrderedSetArgs is () unless ORDERED_SET is true and OrderedSetArgs is configured.

Optional: This function can be skipped, #[pg_aggregate] will create a stub.

Provided methods

Implementors