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