@@ -293,8 +293,8 @@ ALTER FUNCTION public.tlshc(text,text) OWNER TO postgres;
293
293
-- ddl-end --
294
294
295
295
-- object: public.tlsht | type: FUNCTION --
296
- -- DROP FUNCTION IF EXISTS public.tlsht(IN text,IN text,IN int4,int4) CASCADE;
297
- CREATE FUNCTION public .tlsht (IN filter text , IN hash text , IN threshold int4, maxrows int4)
296
+ -- DROP FUNCTION IF EXISTS public.tlsht(IN text,IN text,IN int4,IN int4) CASCADE;
297
+ CREATE FUNCTION public .tlsht (IN filter text , IN hash text , IN threshold int4, IN maxrows int4)
298
298
RETURNS SETOF public .fuzzy_hash
299
299
LANGUAGE plpython3u
300
300
IMMUTABLE LEAKPROOF
@@ -304,19 +304,16 @@ CREATE FUNCTION public.tlsht (IN filter text, IN hash text, IN threshold int4,
304
304
ROWS 1000
305
305
AS $$
306
306
import tlsh
307
- param = [" TLSH" ]
308
- # param[0] = filter
309
- # plan = plpy.prepare("SELECT * FROM fuzzy_hash WHERE type <> $1", ["text"])
310
- # rv = plan.execute(param, maxrows)
311
- rv = plpy .execute (" SELECT * FROM fuzzy_hash" , 1000 )
307
+ plan = plpy .prepare (" SELECT * FROM fuzzy_hash WHERE type <> $1" , [" text" ])
308
+ rv = plan .execute ([" filter" ], maxrows)
312
309
r = []
313
310
for x in rv:
314
- if tlsh .diff (x[" value" ], hash) < threshold:
311
+ if tlsh .diff (x[" value" ], hash) > threshold:
315
312
r .append (x)
316
313
return r
317
314
$$;
318
315
-- ddl-end --
319
- ALTER FUNCTION public .tlsht (IN text ,IN text ,IN int4,int4) OWNER TO postgres;
316
+ ALTER FUNCTION public .tlsht (IN text ,IN text ,IN int4,IN int4) OWNER TO postgres;
320
317
-- ddl-end --
321
318
322
319
0 commit comments