Skip to content

PgAggregateContext

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Owns aggregate execution metadata and provides state storage and native ordering comparisons during its active callback. Metadata remains readable after callback exit; storage lookup and comparison require the exact current context and backend thread.

public sealed class PgAggregateContext

Inheritance: object

Gets the aggregate function OID when an Aggref is available, otherwise null, including window contexts.

public uint? AggregateOid { get; }

Value: uint?

Gets the callback’s input collation OID, or zero when no collation applies.

public uint CollationOid { get; }

Value: uint

Gets whether PostgreSQL can share the transition state with other aggregate evaluations.

public bool IsStateShared { get; }

Value: bool

Gets whether this callback belongs to an aggregate or window executor context.

public PgAggregateContextKind Kind { get; }

Value: PgAggregateContextKind

Gets the borrowed PostgreSQL owner for values retained in this aggregate’s state.

public PgMemoryContext MemoryContext { get; }

Value: PgMemoryContext

Access requires the current aggregate callback. Copy polymorphic inputs here before retaining them in managed state. The returned handle and copied values expire when PostgreSQL resets or deletes the owner, including moving-window restarts and group completion.

Gets immutable ordering keys copied from the aggregate invocation.

public IReadOnlyList<PgAggregateSortKey> SortKeys { get; }

Value: IReadOnlyList<PgAggregateSortKey>

Compares explicitly typed operands using the selected PostgreSQL sort operator, collation and NULL placement. Descriptor-based SpiParameter factories preserve named composite and composite-array identities even when an operand is SQL NULL.

public int Compare(SpiParameter left, SpiParameter right, int sortKey = 0)

Parameters:

left — SpiParameter

The typed left operand, including its PostgreSQL identity when SQL NULL.

right — SpiParameter

The typed right operand, including its PostgreSQL identity when SQL NULL.

sortKey — int

The zero-based index in SortKeys.

Returns: int

A negative value, zero, or a positive value according to PostgreSQL’s ordering.

Compares two values using the selected PostgreSQL sort operator, collation and NULL placement. Use explicitly typed SpiParameter operands when a NULL named composite or composite array has no managed value carrying its identity.

public int Compare<T>(T left, T right, int sortKey = 0)

Type parameters:

T

The managed type of both operands, including nullability for SQL NULL.

Parameters:

left — T

The left operand.

right — T

The right operand.

sortKey — int

The zero-based index in SortKeys.

Returns: int

A negative value, zero, or a positive value according to PostgreSQL’s ordering.