Skip to content

frkn_avg

C aggregate extension providing my_avg for bigint and floating-point inputs.

Aggregate-Average · C aggregate extension providing my_avg for bigint and floating-point inputs.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100215frkn_avgAggregate-Average0.0.1FUNCUnknownC

Usage

Sources:

frkn_avg defines my_avg(bigint) and my_avg(float) aggregates backed by a custom my_state C type. Both accumulate their sum and count using single-precision fields.

CREATE EXTENSION frkn_avg;
SELECT my_avg(v::bigint), my_avg(v::float)
FROM generate_series(1, 10) AS g(v);

This implementation is experimental and has material correctness hazards: the SQL bigint transition is read with a 32-bit C accessor, floating-point input is narrowed, and state precision degrades as values or row counts grow. The declared internal length also differs from the two-float C structure. Do not expose it to untrusted workloads or use it for financial or exact analytics; compare results against PostgreSQL avg on representative data first.

Table reader