2002-07-30 21:34:37 +04:00
|
|
|
-- Adjust this setting to control where the objects get created.
|
|
|
|
SET search_path = public;
|
|
|
|
|
2001-10-13 03:19:09 +04:00
|
|
|
-- TXTIDX type
|
|
|
|
|
2002-08-22 04:01:51 +04:00
|
|
|
CREATE FUNCTION txtidx_in(cstring)
|
|
|
|
RETURNS txtidx
|
2001-10-13 03:19:09 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-08-22 04:01:51 +04:00
|
|
|
CREATE FUNCTION txtidx_out(txtidx)
|
|
|
|
RETURNS cstring
|
2001-10-13 03:19:09 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
CREATE TYPE txtidx (
|
2002-10-18 22:41:22 +04:00
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = txtidx_in,
|
|
|
|
OUTPUT = txtidx_out,
|
|
|
|
STORAGE = extended
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE FUNCTION txt2txtidx(text)
|
|
|
|
RETURNS txtidx
|
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION txtidxsize(txtidx)
|
|
|
|
RETURNS int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
--QUERYTYPES
|
|
|
|
--without morphology
|
2002-08-22 04:01:51 +04:00
|
|
|
CREATE FUNCTION qtxt_in(cstring)
|
|
|
|
RETURNS query_txt
|
2001-10-13 03:19:09 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-08-22 04:01:51 +04:00
|
|
|
CREATE FUNCTION qtxt_out(query_txt)
|
|
|
|
RETURNS cstring
|
2001-10-13 03:19:09 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
CREATE TYPE query_txt (
|
2002-10-18 22:41:22 +04:00
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = qtxt_in,
|
|
|
|
OUTPUT = qtxt_out
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
--with morphology
|
2002-08-22 04:01:51 +04:00
|
|
|
CREATE FUNCTION mqtxt_in(cstring)
|
|
|
|
RETURNS mquery_txt
|
2001-10-13 03:19:09 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-08-22 04:01:51 +04:00
|
|
|
--same C output function as for query_txt
|
|
|
|
CREATE FUNCTION mqtxt_out(mquery_txt)
|
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME', 'qtxt_out'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2002-08-22 04:01:51 +04:00
|
|
|
|
2001-10-13 03:19:09 +04:00
|
|
|
CREATE TYPE mquery_txt (
|
2002-10-18 22:41:22 +04:00
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = mqtxt_in,
|
|
|
|
OUTPUT = mqtxt_out
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
--only for debug
|
|
|
|
CREATE FUNCTION querytree(query_txt)
|
|
|
|
RETURNS text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
CREATE FUNCTION querytree(mquery_txt)
|
|
|
|
RETURNS text
|
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
--operations
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION execqtxt(txtidx, query_txt)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION execqtxt(txtidx, query_txt) IS 'boolean operation with text index';
|
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION execqtxt(txtidx, mquery_txt)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION execqtxt(txtidx, mquery_txt) IS 'boolean operation with text index';
|
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION rexecqtxt(query_txt, txtidx)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION rexecqtxt(query_txt, txtidx) IS 'boolean operation with text index';
|
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION rexecqtxt(mquery_txt, txtidx)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION rexecqtxt(mquery_txt, txtidx) IS 'boolean operation with text index';
|
|
|
|
|
|
|
|
CREATE OPERATOR @@ (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = txtidx,
|
|
|
|
RIGHTARG = query_txt,
|
|
|
|
PROCEDURE = execqtxt,
|
|
|
|
COMMUTATOR = '~@',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR ~@ (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = query_txt,
|
|
|
|
RIGHTARG = txtidx,
|
|
|
|
PROCEDURE = rexecqtxt,
|
|
|
|
COMMUTATOR = '@@',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR ## (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = txtidx,
|
|
|
|
RIGHTARG = mquery_txt,
|
|
|
|
PROCEDURE = execqtxt,
|
|
|
|
COMMUTATOR = '~#',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR ~# (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = mquery_txt,
|
|
|
|
RIGHTARG = txtidx,
|
|
|
|
PROCEDURE = rexecqtxt,
|
|
|
|
COMMUTATOR = '##',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
--Trigger
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION tsearch()
|
|
|
|
RETURNS trigger
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
--GiST
|
|
|
|
--GiST key type
|
2002-08-22 04:01:51 +04:00
|
|
|
CREATE FUNCTION gtxtidx_in(cstring)
|
|
|
|
RETURNS gtxtidx
|
2001-10-13 03:19:09 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-08-22 04:01:51 +04:00
|
|
|
CREATE FUNCTION gtxtidx_out(gtxtidx)
|
|
|
|
RETURNS cstring
|
2001-10-13 03:19:09 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-18 22:41:22 +04:00
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
|
|
|
CREATE TYPE gtxtidx (
|
2002-10-18 22:41:22 +04:00
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = gtxtidx_in,
|
|
|
|
OUTPUT = gtxtidx_out
|
2001-10-13 03:19:09 +04:00
|
|
|
);
|
|
|
|
|
2002-07-30 21:34:37 +04:00
|
|
|
-- support functions
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION gtxtidx_consistent(gtxtidx,internal,int4)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION gtxtidx_compress(internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION gtxtidx_decompress(internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION gtxtidx_penalty(internal,internal,internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C' with (isstrict);
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION gtxtidx_picksplit(internal, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION gtxtidx_union(bytea, internal)
|
|
|
|
RETURNS _int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
CREATE FUNCTION gtxtidx_same(gtxtidx, gtxtidx, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-10-13 03:19:09 +04:00
|
|
|
|
2002-07-30 21:34:37 +04:00
|
|
|
-- create the operator class
|
|
|
|
CREATE OPERATOR CLASS gist_txtidx_ops
|
2002-10-18 22:41:22 +04:00
|
|
|
DEFAULT FOR TYPE txtidx USING gist
|
|
|
|
AS
|
2002-07-30 21:34:37 +04:00
|
|
|
OPERATOR 1 @@ (txtidx, query_txt) RECHECK ,
|
|
|
|
OPERATOR 2 ## (txtidx, mquery_txt) RECHECK ,
|
2002-08-22 04:01:51 +04:00
|
|
|
FUNCTION 1 gtxtidx_consistent (gtxtidx, internal, int4),
|
|
|
|
FUNCTION 2 gtxtidx_union (bytea, internal),
|
|
|
|
FUNCTION 3 gtxtidx_compress (internal),
|
|
|
|
FUNCTION 4 gtxtidx_decompress (internal),
|
|
|
|
FUNCTION 5 gtxtidx_penalty (internal, internal, internal),
|
|
|
|
FUNCTION 6 gtxtidx_picksplit (internal, internal),
|
|
|
|
FUNCTION 7 gtxtidx_same (gtxtidx, gtxtidx, internal),
|
2002-07-30 21:34:37 +04:00
|
|
|
STORAGE gtxtidx;
|