more parameters

master
Jean-Louis Huynen 2019-04-23 15:24:25 +02:00
parent b499781fc6
commit 5fae5f1a74
1 changed files with 6 additions and 9 deletions

View File

@ -293,8 +293,8 @@ ALTER FUNCTION public.tlshc(text,text) OWNER TO postgres;
-- ddl-end --
-- object: public.tlsht | type: FUNCTION --
-- DROP FUNCTION IF EXISTS public.tlsht(IN text,IN text,IN int4,int4) CASCADE;
CREATE FUNCTION public.tlsht (IN filter text, IN hash text, IN threshold int4, maxrows int4)
-- DROP FUNCTION IF EXISTS public.tlsht(IN text,IN text,IN int4,IN int4) CASCADE;
CREATE FUNCTION public.tlsht (IN filter text, IN hash text, IN threshold int4, IN maxrows int4)
RETURNS SETOF public.fuzzy_hash
LANGUAGE plpython3u
IMMUTABLE LEAKPROOF
@ -304,19 +304,16 @@ CREATE FUNCTION public.tlsht (IN filter text, IN hash text, IN threshold int4,
ROWS 1000
AS $$
import tlsh
param = ["TLSH"]
#param[0] = filter
#plan = plpy.prepare("SELECT * FROM fuzzy_hash WHERE type <> $1", ["text"])
#rv = plan.execute(param, maxrows)
rv = plpy.execute("SELECT * FROM fuzzy_hash", 1000)
plan = plpy.prepare("SELECT * FROM fuzzy_hash WHERE type <> $1", ["text"])
rv = plan.execute(["filter"], maxrows)
r = []
for x in rv:
if tlsh.diff(x["value"], hash) < threshold:
if tlsh.diff(x["value"], hash) > threshold:
r.append(x)
return r
$$;
-- ddl-end --
ALTER FUNCTION public.tlsht(IN text,IN text,IN int4,int4) OWNER TO postgres;
ALTER FUNCTION public.tlsht(IN text,IN text,IN int4,IN int4) OWNER TO postgres;
-- ddl-end --