PostgreSQL Script

create schema atscaleudaf;
grant all on schema atscaleudaf to atscaler;
set schema 'atscaleudaf';
UPDATE pg_language SET lanpltrusted = true WHERE lanname LIKE 'c';
SET search_path TO :hllSchema;
create or replace FUNCTION hll_aggregate_accumulate(text, text) returns text as '{postgres_hll_location}', 'hll_aggregate_accumulate' language C;
create or replace FUNCTION hll_estimate_finalize(text) returns int8 as '{postgres_hll_location}', 'hll_estimate_finalize' language C strict;
CREATE AGGREGATE hll_aggregate_estimate(text)
(
sfunc = hll_aggregate_accumulate,
stype = text,
finalfunc = hll_estimate_finalize
);
create or replace FUNCTION hll_aggregate_finalize(text) returns text as '{postgres_hll_location}', 'hll_aggregate_finalize' language C strict;
CREATE AGGREGATE hll_aggregate_merge(text)
(
sfunc = hll_aggregate_accumulate,
stype = text,
finalfunc = hll_aggregate_finalize
);
create or replace FUNCTION hll_value_accumulate(text, anyelement) returns text as '{postgres_hll_location}', 'hll_value_accumulate' language C;
CREATE AGGREGATE hll_estimate(anyelement)
(
sfunc = hll_value_accumulate,
stype = text,
finalfunc = hll_estimate_finalize
);
CREATE AGGREGATE hll_aggregate(anyelement)
(
sfunc = hll_value_accumulate,
stype = text,
finalfunc = hll_aggregate_finalize
);
create or replace FUNCTION atscale_honeybee_version() returns text as '{postgres_hll_location}', 'hll_version' language C;