From 2ffb30d99007d1b8387851ce0697316d6e739e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Nordstr=C3=B6m?= Date: Fri, 17 Nov 2017 12:13:28 +0100 Subject: [PATCH] Make aggregate serialize and deserialize functions STRICT Aggregate functions that have serialize and deserialize support functions (histogram, last, first, etc.) should have these support functions marked STRICT. PostgreSQL's regular test suite will fail when the timescaledb module is loaded without these functions being marked STRICT. --- sql/bookend.sql | 6 ++---- sql/histogram.sql | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sql/bookend.sql b/sql/bookend.sql index 109571cc1..79cad4ddc 100644 --- a/sql/bookend.sql +++ b/sql/bookend.sql @@ -26,12 +26,12 @@ LANGUAGE C IMMUTABLE; CREATE OR REPLACE FUNCTION _timescaledb_internal.bookend_serializefunc(internal) RETURNS bytea AS '$libdir/timescaledb', 'bookend_serializefunc' -LANGUAGE C IMMUTABLE; +LANGUAGE C IMMUTABLE STRICT; CREATE OR REPLACE FUNCTION _timescaledb_internal.bookend_deserializefunc(bytea, internal) RETURNS internal AS '$libdir/timescaledb', 'bookend_deserializefunc' -LANGUAGE C IMMUTABLE; +LANGUAGE C IMMUTABLE STRICT; --This aggregate returns the "first" element of the first argument when ordered by the second argument. --Ex. first(temp, time) returns the temp value for the row with the lowest time @@ -60,5 +60,3 @@ CREATE AGGREGATE last(anyelement, "any") ( FINALFUNC = _timescaledb_internal.bookend_finalfunc, FINALFUNC_EXTRA ); - - diff --git a/sql/histogram.sql b/sql/histogram.sql index 4995aa837..199ca581a 100644 --- a/sql/histogram.sql +++ b/sql/histogram.sql @@ -11,12 +11,12 @@ LANGUAGE C IMMUTABLE; CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_serializefunc(INTERNAL) RETURNS bytea AS '$libdir/timescaledb', 'hist_serializefunc' -LANGUAGE C IMMUTABLE; +LANGUAGE C IMMUTABLE STRICT; CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_deserializefunc(bytea, INTERNAL) RETURNS INTERNAL AS '$libdir/timescaledb', 'hist_deserializefunc' -LANGUAGE C IMMUTABLE; +LANGUAGE C IMMUTABLE STRICT; CREATE OR REPLACE FUNCTION _timescaledb_internal.hist_finalfunc(state INTERNAL, val DOUBLE PRECISION, MIN DOUBLE PRECISION, MAX DOUBLE PRECISION, nbuckets INTEGER) RETURNS INTEGER[]