-
Notifications
You must be signed in to change notification settings - Fork 55
/
rum--1.1--1.2.sql
190 lines (137 loc) · 5.53 KB
/
rum--1.1--1.2.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* RUM version 1.2
*/
/*--------------------anyarray-----------------------*/
CREATE FUNCTION rum_anyarray_config(internal)
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_anyarray_similar(anyarray,anyarray)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT STABLE;
CREATE OPERATOR % (
PROCEDURE = rum_anyarray_similar,
LEFTARG = anyarray,
RIGHTARG = anyarray,
COMMUTATOR = '%',
RESTRICT = contsel,
JOIN = contjoinsel
);
CREATE FUNCTION rum_anyarray_distance(anyarray,anyarray)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT STABLE;
CREATE OPERATOR <=> (
PROCEDURE = rum_anyarray_distance,
LEFTARG = anyarray,
RIGHTARG = anyarray,
COMMUTATOR = '<=>'
);
CREATE FUNCTION rum_extract_anyarray(anyarray,internal,internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_extract_anyarray_query(anyarray,internal,smallint,internal,internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_anyarray_consistent(internal, smallint, anyarray, integer, internal, internal, internal, internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION rum_anyarray_ordering(internal,smallint,anyarray,int,internal,internal,internal,internal,internal)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR CLASS rum_anyarray_ops
DEFAULT FOR TYPE anyarray USING rum
AS
OPERATOR 1 && (anyarray, anyarray),
OPERATOR 2 @> (anyarray, anyarray),
OPERATOR 3 <@ (anyarray, anyarray),
OPERATOR 4 = (anyarray, anyarray),
OPERATOR 5 % (anyarray, anyarray),
OPERATOR 20 <=> (anyarray, anyarray) FOR ORDER BY pg_catalog.float_ops,
--dispatch function 1 for concrete type
FUNCTION 2 rum_extract_anyarray(anyarray,internal,internal,internal,internal),
FUNCTION 3 rum_extract_anyarray_query(anyarray,internal,smallint,internal,internal,internal,internal),
FUNCTION 4 rum_anyarray_consistent(internal,smallint,anyarray,integer,internal,internal,internal,internal),
FUNCTION 6 rum_anyarray_config(internal),
FUNCTION 8 rum_anyarray_ordering(internal,smallint,anyarray,int,internal,internal,internal,internal,internal),
STORAGE anyelement;
CREATE OPERATOR CLASS rum_anyarray_addon_ops
FOR TYPE anyarray USING rum
AS
OPERATOR 1 && (anyarray, anyarray),
OPERATOR 2 @> (anyarray, anyarray),
OPERATOR 3 <@ (anyarray, anyarray),
OPERATOR 4 = (anyarray, anyarray),
--dispatch function 1 for concrete type
FUNCTION 2 ginarrayextract(anyarray,internal,internal),
FUNCTION 3 ginqueryarrayextract(anyarray,internal,smallint,internal,internal,internal,internal),
FUNCTION 4 ginarrayconsistent(internal,smallint,anyarray,integer,internal,internal,internal,internal),
STORAGE anyelement;
/*--------------------int2-----------------------*/
CREATE FUNCTION rum_int2_key_distance(int2, int2, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_int2_ops USING rum ADD
FUNCTION 8 (int2,int2) rum_int2_key_distance(int2, int2, smallint);
/*--------------------int4-----------------------*/
CREATE FUNCTION rum_int4_key_distance(int4, int4, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_int4_ops USING rum ADD
FUNCTION 8 (int4,int4) rum_int4_key_distance(int4, int4, smallint);
/*--------------------int8-----------------------*/
CREATE FUNCTION rum_int8_key_distance(int8, int8, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_int8_ops USING rum ADD
FUNCTION 8 (int8,int8) rum_int8_key_distance(int8, int8, smallint);
/*--------------------float4-----------------------*/
CREATE FUNCTION rum_float4_key_distance(float4, float4, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_float4_ops USING rum ADD
FUNCTION 8 (float4,float4) rum_float4_key_distance(float4, float4, smallint);
/*--------------------float8-----------------------*/
CREATE FUNCTION rum_float8_key_distance(float8, float8, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_float8_ops USING rum ADD
FUNCTION 8 (float8,float8) rum_float8_key_distance(float8, float8, smallint);
/*--------------------money-----------------------*/
CREATE FUNCTION rum_money_key_distance(money, money, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_money_ops USING rum ADD
FUNCTION 8 (money,money) rum_money_key_distance(money, money, smallint);
/*--------------------oid-----------------------*/
CREATE FUNCTION rum_oid_key_distance(oid, oid, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_oid_ops USING rum ADD
FUNCTION 8 (oid,oid) rum_oid_key_distance(oid, oid, smallint);
/*--------------------timestamp-----------------------*/
CREATE FUNCTION rum_timestamp_key_distance(timestamp, timestamp, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_timestamp_ops USING rum ADD
FUNCTION 8 (timestamp,timestamp) rum_timestamp_key_distance(timestamp, timestamp, smallint);
/*--------------------timestamptz-----------------------*/
CREATE FUNCTION rum_timestamptz_key_distance(timestamptz, timestamptz, smallint)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
ALTER OPERATOR FAMILY rum_timestamptz_ops USING rum ADD
FUNCTION 8 (timestamptz,timestamptz) rum_timestamptz_key_distance(timestamptz, timestamptz, smallint);