Commit 4537eeb1 authored by Vasek Sraier's avatar Vasek Sraier

fixed sql initialization, local test from HW-PROBE now succesfully finish

parent 2ffd3dd7
......@@ -7,6 +7,9 @@ psql_rmbt() {
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
}
echo "CREATE EXTENSION IF NOT EXISTS quantile" | psql_rmbt
#psql_rmbt < `pg_config --sharedir`/extension/quantile--1.1.5.sql
echo "CREATE EXTENSION IF NOT EXISTS hstore;" | psql_rmbt
echo 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' | psql_rmbt
......
......@@ -212,6 +212,70 @@ $$;
ALTER FUNCTION public.rmbt_set_provider_from_as(_test_id bigint) OWNER TO rmbt;
--
-- Name: random_sync_code(integer); Type: FUNCTION; Schema: public; Owner: rmbt
--
CREATE FUNCTION public.random_sync_code(integer) RETURNS text
LANGUAGE sql
AS $_$
select upper(
substring(
(
SELECT string_agg(md5(random()::TEXT), '')
FROM generate_series(1, CEIL($1 / 32.)::integer)
),
(33-$1))
);
$_$;
ALTER FUNCTION public.random_sync_code(integer) OWNER TO rmbt;
--
-- Name: _final_median(anyarray); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION public._final_median(anyarray) RETURNS double precision
LANGUAGE sql IMMUTABLE
AS $_$
WITH q AS
(
SELECT val
FROM unnest($1) val
WHERE VAL IS NOT NULL
ORDER BY 1
),
cnt AS
(
SELECT COUNT(*) AS c FROM q
)
SELECT AVG(val)::float8
FROM
(
SELECT val FROM q
LIMIT 2 - MOD((SELECT c FROM cnt), 2)
OFFSET GREATEST(CEIL((SELECT c FROM cnt) / 2.0) - 1,0)
) q2;
$_$;
ALTER FUNCTION public._final_median(anyarray) OWNER TO rmbt;
CREATE AGGREGATE public.median(anyelement) (
SFUNC = array_append,
STYPE = anyarray,
INITCOND = '{}',
FINALFUNC = public._final_median
);
ALTER AGGREGATE public.median(anyelement) OWNER TO rmbt;
--
-- TOC entry 1275 (class 1255 OID 73382)
-- Name: trigger_test(); Type: FUNCTION; Schema: public; Owner: rmbt
......@@ -412,7 +476,7 @@ BEGIN
NEW.timestamp = now();
SELECT INTO NEW.location_max_distance
round(|/((xmax(st_extent(location))-xmin(st_extent(location)))^2+(ymax(st_extent(location))-ymin(st_extent(location)))^2))
round(|/((st_xmax(st_extent(location))-st_xmin(st_extent(location)))^2+(st_ymax(st_extent(location))-st_ymin(st_extent(location)))^2))
FROM geo_location
WHERE test_id=NEW.uid;
END IF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment