mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 18:43:18 +08:00
A rebase with only minor modifications from commit e80720dd9b412a31d1079533323d0b01231926e3
38 lines
1.6 KiB
SQL
38 lines
1.6 KiB
SQL
CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_sfunc (state INTERNAL, val DOUBLE PRECISION, MIN DOUBLE PRECISION, MAX DOUBLE PRECISION, nbuckets INTEGER)
|
|
RETURNS INTERNAL
|
|
AS '$libdir/timescaledb', 'hist_sfunc'
|
|
LANGUAGE C IMMUTABLE;
|
|
|
|
CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_combinefunc(state1 INTERNAL, state2 INTERNAL)
|
|
RETURNS INTERNAL
|
|
AS '$libdir/timescaledb', 'hist_combinefunc'
|
|
LANGUAGE C IMMUTABLE;
|
|
|
|
CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_serializefunc(INTERNAL)
|
|
RETURNS bytea
|
|
AS '$libdir/timescaledb', 'hist_serializefunc'
|
|
LANGUAGE C IMMUTABLE;
|
|
|
|
CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_deserializefunc(bytea, INTERNAL)
|
|
RETURNS INTERNAL
|
|
AS '$libdir/timescaledb', 'hist_deserializefunc'
|
|
LANGUAGE C IMMUTABLE;
|
|
|
|
CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_finalfunc(state INTERNAL, val DOUBLE PRECISION, MIN DOUBLE PRECISION, MAX DOUBLE PRECISION, nbuckets INTEGER)
|
|
RETURNS INTEGER[]
|
|
AS '$libdir/timescaledb', 'hist_finalfunc'
|
|
LANGUAGE C IMMUTABLE;
|
|
|
|
-- Tell Postgres how to use the new function
|
|
DROP AGGREGATE IF EXISTS histogram (DOUBLE PRECISION, DOUBLE PRECISION, DOUBLE PRECISION, INTEGER);
|
|
CREATE AGGREGATE histogram (DOUBLE PRECISION, DOUBLE PRECISION, DOUBLE PRECISION, INTEGER) (
|
|
SFUNC = _timescaledb_internal.hist_sfunc,
|
|
STYPE = INTERNAL,
|
|
COMBINEFUNC = _timescaledb_internal.hist_combinefunc,
|
|
SERIALFUNC = _timescaledb_internal.hist_serializefunc,
|
|
DESERIALFUNC = _timescaledb_internal.hist_deserializefunc,
|
|
PARALLEL = SAFE,
|
|
FINALFUNC = _timescaledb_internal.hist_finalfunc,
|
|
FINALFUNC_EXTRA
|
|
);
|