-
Notifications
You must be signed in to change notification settings - Fork 5
/
rum_support.sql
122 lines (107 loc) · 4.81 KB
/
rum_support.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
CREATE FUNCTION rum_extract_tsvector2(tsvector2,internal,internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
CREATE FUNCTION rum_extract_tsvector2_hash(tsvector2,internal,internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION install_rum_for_tsvector2()
RETURNS VOID AS $$
DECLARE found BOOL;
BEGIN
CREATE FUNCTION rum_ts_distance(tsvector2,tsquery)
RETURNS float4
AS 'MODULE_PATHNAME', 'rum_ts_distance_tt'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_ts_distance(tsvector2,tsquery,int)
RETURNS float4
AS 'MODULE_PATHNAME', 'rum_ts_distance_ttf'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_ts_distance(tsvector2,rum_distance_query)
RETURNS float4
AS 'MODULE_PATHNAME', 'rum_ts_distance_td'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_ts_score(tsvector2,tsquery)
RETURNS float4
AS 'MODULE_PATHNAME', 'rum_ts_score_tt'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_ts_score(tsvector2,tsquery,int)
RETURNS float4
AS 'MODULE_PATHNAME', 'rum_ts_score_ttf'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_ts_score(tsvector2,rum_distance_query)
RETURNS float4
AS 'MODULE_PATHNAME', 'rum_ts_score_td'
LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR <=> (
LEFTARG = tsvector2,
RIGHTARG = tsquery,
PROCEDURE = rum_ts_distance
);
CREATE OPERATOR <=> (
LEFTARG = tsvector2,
RIGHTARG = rum_distance_query,
PROCEDURE = rum_ts_distance
);
CREATE OPERATOR CLASS rum_tsvector2_ops
DEFAULT FOR TYPE tsvector2 USING rum
AS
OPERATOR 1 @@ (tsvector2, tsquery),
OPERATOR 2 <=> (tsvector2, tsquery) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 gin_cmp_tslexeme(text, text),
FUNCTION 2 rum_extract_tsvector2(tsvector2,internal,internal,internal,internal),
FUNCTION 3 rum_extract_tsquery(tsquery,internal,smallint,internal,internal,internal,internal),
FUNCTION 4 rum_tsquery_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
FUNCTION 5 gin_cmp_prefix(text,text,smallint,internal),
FUNCTION 6 rum_tsvector_config(internal),
FUNCTION 7 rum_tsquery_pre_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
FUNCTION 8 rum_tsquery_distance(internal,smallint,tsvector,int,internal,internal,internal,internal,internal),
FUNCTION 10 rum_ts_join_pos(internal, internal),
STORAGE text;
CREATE OPERATOR CLASS rum_tsvector2_hash_ops
FOR TYPE tsvector2 USING rum
AS
OPERATOR 1 @@ (tsvector2, tsquery),
OPERATOR 2 <=> (tsvector2, tsquery) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 btint4cmp(integer, integer),
FUNCTION 2 rum_extract_tsvector2_hash(tsvector2,internal,internal,internal,internal),
FUNCTION 3 rum_extract_tsquery_hash(tsquery,internal,smallint,internal,internal,internal,internal),
FUNCTION 4 rum_tsquery_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
FUNCTION 6 rum_tsvector_config(internal),
FUNCTION 7 rum_tsquery_pre_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
FUNCTION 8 rum_tsquery_distance(internal,smallint,tsvector,int,internal,internal,internal,internal,internal),
FUNCTION 10 rum_ts_join_pos(internal, internal),
STORAGE integer;
CREATE OPERATOR CLASS rum_tsvector2_addon_ops
FOR TYPE tsvector2 USING rum
AS
OPERATOR 1 @@ (tsvector2, tsquery),
--support function
FUNCTION 1 gin_cmp_tslexeme(text, text),
FUNCTION 2 rum_extract_tsvector2(tsvector2,internal,internal,internal,internal),
FUNCTION 3 rum_extract_tsquery(tsquery,internal,smallint,internal,internal,internal,internal),
FUNCTION 4 rum_tsquery_addon_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
FUNCTION 5 gin_cmp_prefix(text,text,smallint,internal),
FUNCTION 7 rum_tsquery_pre_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
STORAGE text;
CREATE OPERATOR CLASS rum_tsvector2_hash_addon_ops
FOR TYPE tsvector2 USING rum
AS
OPERATOR 1 @@ (tsvector2, tsquery),
--support function
FUNCTION 1 btint4cmp(integer, integer),
FUNCTION 2 rum_extract_tsvector2_hash(tsvector2,internal,internal,internal,internal),
FUNCTION 3 rum_extract_tsquery_hash(tsquery,internal,smallint,internal,internal,internal,internal),
FUNCTION 4 rum_tsquery_addon_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
FUNCTION 7 rum_tsquery_pre_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
STORAGE integer;
END;
$$ LANGUAGE plpgsql;
-- rum support if it's installed
DO LANGUAGE plpgsql $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_am WHERE amname = 'rum') THEN
PERFORM install_rum_for_tsvector2();
END IF;
END$$;