pg_hamming/install.sh
2020-05-23 14:45:23 -04:00

25 lines
991 B
Bash
Executable File

#!/usr/bin/env bash
LIB_PATH="'/usr/lib/libhamming.so'"
psql -U $POSTGRES_USER $POSTGRES_DB <<EOF
CREATE OR REPLACE FUNCTION hash_is_within_distance8(bytea, bytea, integer) RETURNS boolean
AS $LIB_PATH, 'hash_is_within_distance8' LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION hash_is_within_distance32(bytea, bytea, integer) RETURNS boolean
AS $LIB_PATH, 'hash_is_within_distance32'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION hash_is_within_distance128(bytea, bytea, integer) RETURNS boolean
AS $LIB_PATH, 'hash_is_within_distance128'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION hash_distance8(bytea, bytea) RETURNS integer
AS $LIB_PATH, 'hash_distance8'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION hash_distance32(bytea, bytea) RETURNS integer
AS $LIB_PATH, 'hash_distance32'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION hash_distance128(bytea, bytea) RETURNS integer
AS $LIB_PATH, 'hash_distance128'
LANGUAGE C STRICT;
EOF