1 -- Create the user-defined type for the 1-D integer arrays (_int4)
6 -- External C-functions for R-tree methods
11 CREATE FUNCTION _int_contains(_int4, _int4) RETURNS bool
12 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
14 COMMENT ON FUNCTION _int_contains(_int4, _int4) IS 'contains';
16 CREATE FUNCTION _int_contained(_int4, _int4) RETURNS bool
17 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
19 COMMENT ON FUNCTION _int_contained(_int4, _int4) IS 'contained in';
21 CREATE FUNCTION _int_overlap(_int4, _int4) RETURNS bool
22 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
24 COMMENT ON FUNCTION _int_overlap(_int4, _int4) IS 'overlaps';
26 CREATE FUNCTION _int_same(_int4, _int4) RETURNS bool
27 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
29 COMMENT ON FUNCTION _int_same(_int4, _int4) IS 'same as';
31 CREATE FUNCTION _int_different(_int4, _int4) RETURNS bool
32 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
34 COMMENT ON FUNCTION _int_different(_int4, _int4) IS 'different';
36 -- support routines for indexing
38 CREATE FUNCTION _int_union(_int4, _int4) RETURNS _int4
39 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
41 CREATE FUNCTION _int_inter(_int4, _int4) RETURNS _int4
42 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
49 LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_overlap,
51 RESTRICT = contsel, JOIN = contjoinsel
55 -- LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_same,
56 -- COMMUTATOR = '=', NEGATOR = '<>',
57 -- RESTRICT = eqsel, JOIN = eqjoinsel,
58 -- SORT1 = '<', SORT2 = '<'
62 LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_different,
63 COMMUTATOR = '<>', NEGATOR = '=',
64 RESTRICT = neqsel, JOIN = neqjoinsel
68 LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_contains,
69 COMMUTATOR = '~', RESTRICT = contsel, JOIN = contjoinsel
73 LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_contained,
74 COMMUTATOR = '@', RESTRICT = contsel, JOIN = contjoinsel
78 -- define the GiST support methods
79 CREATE FUNCTION g_int_consistent(opaque,_int4,int4) RETURNS bool
80 AS 'MODULE_PATHNAME' LANGUAGE 'c';
82 CREATE FUNCTION g_int_compress(opaque) RETURNS opaque
83 AS 'MODULE_PATHNAME' LANGUAGE 'c';
85 CREATE FUNCTION g_int_decompress(opaque) RETURNS opaque
86 AS 'MODULE_PATHNAME' LANGUAGE 'c';
88 CREATE FUNCTION g_int_penalty(opaque,opaque,opaque) RETURNS opaque
89 AS 'MODULE_PATHNAME' LANGUAGE 'c';
91 CREATE FUNCTION g_int_picksplit(opaque, opaque) RETURNS opaque
92 AS 'MODULE_PATHNAME' LANGUAGE 'c';
94 CREATE FUNCTION g_int_union(bytea, opaque) RETURNS _int4
95 AS 'MODULE_PATHNAME' LANGUAGE 'c';
97 CREATE FUNCTION g_int_same(_int4, _int4, opaque) RETURNS opaque
98 AS 'MODULE_PATHNAME' LANGUAGE 'c';
101 -- register the default opclass for indexing
102 INSERT INTO pg_opclass (opcname, opcdeftype)
103 SELECT 'gist__int_ops', oid
105 WHERE typname = '_int4';
108 -- get the comparators for _intments and store them in a tmp table
109 SELECT o.oid AS opoid, o.oprname
110 INTO TABLE _int_ops_tmp
111 FROM pg_operator o, pg_type t
112 WHERE o.oprleft = t.oid and o.oprright = t.oid
113 and t.typname = '_int4';
115 -- make sure we have the right operators
116 -- SELECT * from _int_ops_tmp;
118 -- using the tmp table, generate the amop entries
121 INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
122 SELECT am.oid, opcl.oid, c.opoid, 3
123 FROM pg_am am, pg_opclass opcl, _int_ops_tmp c
124 WHERE amname = 'gist' and opcname = 'gist__int_ops'
125 and c.oprname = '&&';
128 INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
129 SELECT am.oid, opcl.oid, c.opoid, 6
130 FROM pg_am am, pg_opclass opcl, _int_ops_tmp c
131 WHERE amname = 'gist' and opcname = 'gist__int_ops'
135 INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
136 SELECT am.oid, opcl.oid, c.opoid, 7
137 FROM pg_am am, pg_opclass opcl, _int_ops_tmp c
138 WHERE amname = 'gist' and opcname = 'gist__int_ops'
142 INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
143 SELECT am.oid, opcl.oid, c.opoid, 8
144 FROM pg_am am, pg_opclass opcl, _int_ops_tmp c
145 WHERE amname = 'gist' and opcname = 'gist__int_ops'
148 DROP TABLE _int_ops_tmp;
151 -- add the entries to amproc for the support methods
152 -- note the amprocnum numbers associated with each are specific!
154 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
155 SELECT am.oid, opcl.oid, pro.oid, 1
156 FROM pg_am am, pg_opclass opcl, pg_proc pro
157 WHERE amname = 'gist' and opcname = 'gist__int_ops'
158 and proname = 'g_int_consistent';
160 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
161 SELECT am.oid, opcl.oid, pro.oid, 2
162 FROM pg_am am, pg_opclass opcl, pg_proc pro
163 WHERE amname = 'gist' and opcname = 'gist__int_ops'
164 and proname = 'g_int_union';
166 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
167 SELECT am.oid, opcl.oid, pro.oid, 3
168 FROM pg_am am, pg_opclass opcl, pg_proc pro
169 WHERE amname = 'gist' and opcname = 'gist__int_ops'
170 and proname = 'g_int_compress';
172 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
173 SELECT am.oid, opcl.oid, pro.oid, 4
174 FROM pg_am am, pg_opclass opcl, pg_proc pro
175 WHERE amname = 'gist' and opcname = 'gist__int_ops'
176 and proname = 'g_int_decompress';
178 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
179 SELECT am.oid, opcl.oid, pro.oid, 5
180 FROM pg_am am, pg_opclass opcl, pg_proc pro
181 WHERE amname = 'gist' and opcname = 'gist__int_ops'
182 and proname = 'g_int_penalty';
184 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
185 SELECT am.oid, opcl.oid, pro.oid, 6
186 FROM pg_am am, pg_opclass opcl, pg_proc pro
187 WHERE amname = 'gist' and opcname = 'gist__int_ops'
188 and proname = 'g_int_picksplit';
190 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
191 SELECT am.oid, opcl.oid, pro.oid, 7
192 FROM pg_am am, pg_opclass opcl, pg_proc pro
193 WHERE amname = 'gist' and opcname = 'gist__int_ops'
194 and proname = 'g_int_same';
197 ---------------------------------------------
199 ---------------------------------------------
200 -- define the GiST support methods
201 CREATE FUNCTION g_intbig_consistent(opaque,_int4,int4) RETURNS bool
202 AS 'MODULE_PATHNAME' LANGUAGE 'c';
204 CREATE FUNCTION g_intbig_compress(opaque) RETURNS opaque
205 AS 'MODULE_PATHNAME' LANGUAGE 'c';
207 CREATE FUNCTION g_intbig_decompress(opaque) RETURNS opaque
208 AS 'MODULE_PATHNAME' LANGUAGE 'c';
210 CREATE FUNCTION g_intbig_penalty(opaque,opaque,opaque) RETURNS opaque
211 AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
213 CREATE FUNCTION g_intbig_picksplit(opaque, opaque) RETURNS opaque
214 AS 'MODULE_PATHNAME' LANGUAGE 'c';
216 CREATE FUNCTION g_intbig_union(bytea, opaque) RETURNS _int4
217 AS 'MODULE_PATHNAME' LANGUAGE 'c';
219 CREATE FUNCTION g_intbig_same(_int4, _int4, opaque) RETURNS opaque
220 AS 'MODULE_PATHNAME' LANGUAGE 'c';
222 -- register the default opclass for indexing
223 INSERT INTO pg_opclass (opcname, opcdeftype)
224 values ( 'gist__intbig_ops', 0 );
227 -- get the comparators for _intments and store them in a tmp table
228 SELECT o.oid AS opoid, o.oprname
229 INTO TABLE _int_ops_tmp
230 FROM pg_operator o, pg_type t
231 WHERE o.oprleft = t.oid and o.oprright = t.oid
232 and t.typname = '_int4';
234 -- make sure we have the right operators
235 -- SELECT * from _int_ops_tmp;
237 -- using the tmp table, generate the amop entries
240 INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
241 SELECT am.oid, opcl.oid, c.opoid, 3
242 FROM pg_am am, pg_opclass opcl, _int_ops_tmp c
243 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
244 and c.oprname = '&&';
247 INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
248 SELECT am.oid, opcl.oid, c.opoid, 7
249 FROM pg_am am, pg_opclass opcl, _int_ops_tmp c
250 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
254 INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
255 SELECT am.oid, opcl.oid, c.opoid, 8
256 FROM pg_am am, pg_opclass opcl, _int_ops_tmp c
257 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
260 DROP TABLE _int_ops_tmp;
263 -- add the entries to amproc for the support methods
264 -- note the amprocnum numbers associated with each are specific!
266 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
267 SELECT am.oid, opcl.oid, pro.oid, 1
268 FROM pg_am am, pg_opclass opcl, pg_proc pro
269 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
270 and proname = 'g_intbig_consistent';
272 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
273 SELECT am.oid, opcl.oid, pro.oid, 2
274 FROM pg_am am, pg_opclass opcl, pg_proc pro
275 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
276 and proname = 'g_intbig_union';
278 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
279 SELECT am.oid, opcl.oid, pro.oid, 3
280 FROM pg_am am, pg_opclass opcl, pg_proc pro
281 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
282 and proname = 'g_intbig_compress';
284 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
285 SELECT am.oid, opcl.oid, pro.oid, 4
286 FROM pg_am am, pg_opclass opcl, pg_proc pro
287 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
288 and proname = 'g_intbig_decompress';
290 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
291 SELECT am.oid, opcl.oid, pro.oid, 5
292 FROM pg_am am, pg_opclass opcl, pg_proc pro
293 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
294 and proname = 'g_intbig_penalty';
296 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
297 SELECT am.oid, opcl.oid, pro.oid, 6
298 FROM pg_am am, pg_opclass opcl, pg_proc pro
299 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
300 and proname = 'g_intbig_picksplit';
302 INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
303 SELECT am.oid, opcl.oid, pro.oid, 7
304 FROM pg_am am, pg_opclass opcl, pg_proc pro
305 WHERE amname = 'gist' and opcname = 'gist__intbig_ops'
306 and proname = 'g_intbig_same';