2007-11-11 11:25:35 +08:00
|
|
|
-- Adjust this setting to control where the objects get created.
|
2004-06-01 01:18:12 +08:00
|
|
|
SET search_path = public;
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION set_limit(float4)
|
|
|
|
RETURNS float4
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION show_limit()
|
|
|
|
RETURNS float4
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION show_trgm(text)
|
|
|
|
RETURNS _text
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION similarity(text,text)
|
|
|
|
RETURNS float4
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION similarity_op(text,text)
|
|
|
|
RETURNS bool
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR % (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = similarity_op,
|
|
|
|
COMMUTATOR = '%',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
2007-03-14 22:15:40 +08:00
|
|
|
-- gist key
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_in(cstring)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS gtrgm
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_out(gtrgm)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
|
|
|
CREATE TYPE gtrgm (
|
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = gtrgm_in,
|
|
|
|
OUTPUT = gtrgm_out
|
|
|
|
);
|
|
|
|
|
2007-03-14 22:15:40 +08:00
|
|
|
-- support functions for gist
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_consistent(gtrgm,internal,int4)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_compress(internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_decompress(internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_penalty(internal,internal,internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_picksplit(internal, internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_union(bytea, internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS _int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gtrgm_same(gtrgm, gtrgm, internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-03-14 22:15:40 +08:00
|
|
|
-- create the operator class for gist
|
2004-06-01 01:18:12 +08: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 22:15:40 +08:00
|
|
|
-- support functions for gin
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gin_extract_trgm(text, internal)
|
2007-03-14 22:15:40 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2007-03-14 22:15:40 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gin_extract_trgm(text, internal, internal)
|
2007-03-14 22:15:40 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2007-03-14 22:15:40 +08:00
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
CREATE OR REPLACE FUNCTION gin_trgm_consistent(internal, internal, text)
|
2007-03-14 22:15:40 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C IMMUTABLE;
|
2007-03-14 22:15:40 +08: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;
|