2004-05-31 21:18:12 +04:00
|
|
|
SET search_path = public;
|
|
|
|
|
|
|
|
BEGIN;
|
|
|
|
|
|
|
|
create function set_limit(float4)
|
|
|
|
returns float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
create function show_limit()
|
|
|
|
returns float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
create function show_trgm(text)
|
|
|
|
returns _text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
create function similarity(text,text)
|
|
|
|
returns float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
create function similarity_op(text,text)
|
|
|
|
returns bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE OPERATOR % (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = similarity_op,
|
|
|
|
COMMUTATOR = '%',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
2007-03-14 17:15:40 +03:00
|
|
|
-- gist key
|
2004-05-31 21:18:12 +04:00
|
|
|
CREATE FUNCTION gtrgm_in(cstring)
|
|
|
|
RETURNS gtrgm
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION gtrgm_out(gtrgm)
|
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE TYPE gtrgm (
|
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = gtrgm_in,
|
|
|
|
OUTPUT = gtrgm_out
|
|
|
|
);
|
|
|
|
|
2007-03-14 17:15:40 +03:00
|
|
|
-- support functions for gist
|
2004-05-31 21:18:12 +04:00
|
|
|
CREATE FUNCTION gtrgm_consistent(gtrgm,internal,int4)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION gtrgm_compress(internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION gtrgm_decompress(internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION gtrgm_penalty(internal,internal,internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION gtrgm_picksplit(internal, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION gtrgm_union(bytea, internal)
|
|
|
|
RETURNS _int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION gtrgm_same(gtrgm, gtrgm, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
2007-03-14 17:15:40 +03:00
|
|
|
-- create the operator class for gist
|
2004-05-31 21:18:12 +04:00
|
|
|
CREATE OPERATOR CLASS gist_trgm_ops
|
|
|
|
FOR TYPE text USING gist
|
|
|
|
AS
|
|
|
|
OPERATOR 1 % (text, text),
|
|
|
|
FUNCTION 1 gtrgm_consistent (gtrgm, internal, int4),
|
|
|
|
FUNCTION 2 gtrgm_union (bytea, internal),
|
|
|
|
FUNCTION 3 gtrgm_compress (internal),
|
|
|
|
FUNCTION 4 gtrgm_decompress (internal),
|
|
|
|
FUNCTION 5 gtrgm_penalty (internal, internal, internal),
|
|
|
|
FUNCTION 6 gtrgm_picksplit (internal, internal),
|
|
|
|
FUNCTION 7 gtrgm_same (gtrgm, gtrgm, internal),
|
|
|
|
STORAGE gtrgm;
|
|
|
|
|
2007-03-14 17:15:40 +03:00
|
|
|
-- support functions for gin
|
|
|
|
CREATE FUNCTION gin_extract_trgm(text, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2007-03-14 17:15:40 +03:00
|
|
|
|
|
|
|
CREATE FUNCTION gin_extract_trgm(text, internal, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2007-03-14 17:15:40 +03:00
|
|
|
|
|
|
|
CREATE FUNCTION gin_trgm_consistent(internal, internal, text)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 19:52:06 +04:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2007-03-14 17:15:40 +03:00
|
|
|
|
|
|
|
-- create the operator class for gin
|
|
|
|
CREATE OPERATOR CLASS gin_trgm_ops
|
|
|
|
FOR TYPE text USING gin
|
|
|
|
AS
|
|
|
|
OPERATOR 1 % (text, text) RECHECK,
|
|
|
|
FUNCTION 1 btint4cmp (int4, int4),
|
|
|
|
FUNCTION 2 gin_extract_trgm (text, internal),
|
|
|
|
FUNCTION 3 gin_extract_trgm (text, internal, internal),
|
|
|
|
FUNCTION 4 gin_trgm_consistent (internal, internal, text),
|
|
|
|
STORAGE int4;
|
2004-05-31 21:18:12 +04:00
|
|
|
|
|
|
|
COMMIT;
|