summaryrefslogtreecommitdiff
path: root/contrib/tsearch2/tsearch.sql.in
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2004-03-25 16:56:10 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2004-03-25 16:56:10 +0000
commiteebdfcdbe6e3ee7432229ac51e37d9a422836fda (patch)
tree916627d5b49a9aa4ed306fe693866f76dd78404c /contrib/tsearch2/tsearch.sql.in
parent457ad3925de8bd1a2ae025a05d60862d2f98f611 (diff)
downloadpostgresql-eebdfcdbe6e3ee7432229ac51e37d9a422836fda.tar.gz
1 Minimize memory allocation for void (but not null) value.
2 Add silly ordering for ts_vector to aim grouping, union, except etc. Don't use BTree opclass (tsvector_ops).
Diffstat (limited to 'contrib/tsearch2/tsearch.sql.in')
-rw-r--r--contrib/tsearch2/tsearch.sql.in106
1 files changed, 106 insertions, 0 deletions
diff --git a/contrib/tsearch2/tsearch.sql.in b/contrib/tsearch2/tsearch.sql.in
index bb5fc5a6a2..71925beed8 100644
--- a/contrib/tsearch2/tsearch.sql.in
+++ b/contrib/tsearch2/tsearch.sql.in
@@ -702,6 +702,112 @@ where
c.oid=show_curcfg()
' language 'SQL' with(isstrict);
+--compare functions
+CREATE FUNCTION tsvector_cmp(tsvector,tsvector)
+RETURNS int4
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE FUNCTION tsvector_lt(tsvector,tsvector)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE FUNCTION tsvector_le(tsvector,tsvector)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE FUNCTION tsvector_eq(tsvector,tsvector)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE FUNCTION tsvector_ge(tsvector,tsvector)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE FUNCTION tsvector_gt(tsvector,tsvector)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE FUNCTION tsvector_ne(tsvector,tsvector)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' WITH (isstrict,iscachable);
+
+CREATE OPERATOR < (
+ LEFTARG = tsvector,
+ RIGHTARG = tsvector,
+ PROCEDURE = tsvector_lt,
+ COMMUTATOR = '>',
+ NEGATOR = '>=',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+CREATE OPERATOR <= (
+ LEFTARG = tsvector,
+ RIGHTARG = tsvector,
+ PROCEDURE = tsvector_le,
+ COMMUTATOR = '>=',
+ NEGATOR = '>',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+CREATE OPERATOR >= (
+ LEFTARG = tsvector,
+ RIGHTARG = tsvector,
+ PROCEDURE = tsvector_ge,
+ COMMUTATOR = '<=',
+ NEGATOR = '<',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+CREATE OPERATOR > (
+ LEFTARG = tsvector,
+ RIGHTARG = tsvector,
+ PROCEDURE = tsvector_gt,
+ COMMUTATOR = '<',
+ NEGATOR = '<=',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+CREATE OPERATOR = (
+ LEFTARG = tsvector,
+ RIGHTARG = tsvector,
+ PROCEDURE = tsvector_eq,
+ COMMUTATOR = '=',
+ NEGATOR = '<>',
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ SORT1 = '<',
+ SORT2 = '<'
+);
+
+CREATE OPERATOR <> (
+ LEFTARG = tsvector,
+ RIGHTARG = tsvector,
+ PROCEDURE = tsvector_ne,
+ COMMUTATOR = '<>',
+ NEGATOR = '=',
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel
+);
+
+CREATE OPERATOR CLASS tsvector_ops
+ DEFAULT FOR TYPE tsvector USING btree AS
+ OPERATOR 1 < ,
+ OPERATOR 2 <= ,
+ OPERATOR 3 = ,
+ OPERATOR 4 >= ,
+ OPERATOR 5 > ,
+ FUNCTION 1 tsvector_cmp(tsvector, tsvector);
--example of ISpell dictionary
--update pg_ts_dict set dict_initoption='DictFile="/usr/local/share/ispell/russian.dict" ,AffFile ="/usr/local/share/ispell/russian.aff", StopFile="/usr/local/share/ispell/russian.stop"' where dict_id=4;