ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/bioseg/trunk/bioseg0.sql
Revision: 13
Committed: Sat Nov 17 17:56:35 2007 UTC (12 years ago) by kmr
File size: 9213 byte(s)
Log Message:
Fixed INTERBASE_COORDS tests.

Line User Rev File contents
1 kmr 6 -- Create the user-defined type for 1-D integer intervals (bioseg)
2     --
3    
4     -- Adjust this setting to control where the objects get created.
5     SET search_path = public;
6    
7     CREATE FUNCTION bioseg0_in(cstring)
8     RETURNS bioseg0
9     AS '$libdir/bioseg0'
10     LANGUAGE C STRICT IMMUTABLE;
11    
12     CREATE FUNCTION bioseg0_out(bioseg0)
13     RETURNS cstring
14     AS '$libdir/bioseg0'
15     LANGUAGE C STRICT IMMUTABLE;
16    
17     CREATE FUNCTION bioseg0_create(int4, int4)
18     RETURNS bioseg0
19     AS '$libdir/bioseg0'
20     LANGUAGE C STRICT IMMUTABLE;
21    
22     CREATE TYPE bioseg0 (
23     INTERNALLENGTH = 8,
24     INPUT = bioseg0_in,
25     OUTPUT = bioseg0_out
26     );
27    
28     COMMENT ON TYPE bioseg0 IS
29     'integer point interval ''INT..INT'' or ''INT''';
30    
31     --
32     -- External C-functions for R-tree methods
33     --
34    
35     -- Left/Right methods
36    
37     CREATE FUNCTION bioseg0_over_left(bioseg0, bioseg0)
38     RETURNS bool
39     AS '$libdir/bioseg0'
40     LANGUAGE C STRICT IMMUTABLE;
41    
42     COMMENT ON FUNCTION bioseg0_over_left(bioseg0, bioseg0) IS
43     'overlaps or is left of';
44    
45     CREATE FUNCTION bioseg0_over_right(bioseg0, bioseg0)
46     RETURNS bool
47     AS '$libdir/bioseg0'
48     LANGUAGE C STRICT IMMUTABLE;
49    
50     COMMENT ON FUNCTION bioseg0_over_right(bioseg0, bioseg0) IS
51     'overlaps or is right of';
52    
53     CREATE FUNCTION bioseg0_left(bioseg0, bioseg0)
54     RETURNS bool
55     AS '$libdir/bioseg0'
56     LANGUAGE C STRICT IMMUTABLE;
57    
58     COMMENT ON FUNCTION bioseg0_left(bioseg0, bioseg0) IS
59     'is left of';
60    
61     CREATE FUNCTION bioseg0_right(bioseg0, bioseg0)
62     RETURNS bool
63     AS '$libdir/bioseg0'
64     LANGUAGE C STRICT IMMUTABLE;
65    
66     COMMENT ON FUNCTION bioseg0_right(bioseg0, bioseg0) IS
67     'is right of';
68    
69    
70     -- Scalar comparison methods
71    
72     CREATE FUNCTION bioseg0_lt(bioseg0, bioseg0)
73     RETURNS bool
74     AS '$libdir/bioseg0'
75     LANGUAGE C STRICT IMMUTABLE;
76    
77     COMMENT ON FUNCTION bioseg0_lt(bioseg0, bioseg0) IS
78     'less than';
79    
80     CREATE FUNCTION bioseg0_le(bioseg0, bioseg0)
81     RETURNS bool
82     AS '$libdir/bioseg0'
83     LANGUAGE C STRICT IMMUTABLE;
84    
85     COMMENT ON FUNCTION bioseg0_le(bioseg0, bioseg0) IS
86     'less than or equal';
87    
88     CREATE FUNCTION bioseg0_gt(bioseg0, bioseg0)
89     RETURNS bool
90     AS '$libdir/bioseg0'
91     LANGUAGE C STRICT IMMUTABLE;
92    
93     COMMENT ON FUNCTION bioseg0_gt(bioseg0, bioseg0) IS
94     'greater than';
95    
96     CREATE FUNCTION bioseg0_ge(bioseg0, bioseg0)
97     RETURNS bool
98     AS '$libdir/bioseg0'
99     LANGUAGE C STRICT IMMUTABLE;
100    
101     COMMENT ON FUNCTION bioseg0_ge(bioseg0, bioseg0) IS
102     'greater than or equal';
103    
104     CREATE FUNCTION bioseg0_contains(bioseg0, bioseg0)
105     RETURNS bool
106     AS '$libdir/bioseg0'
107     LANGUAGE C STRICT IMMUTABLE;
108    
109     COMMENT ON FUNCTION bioseg0_contains(bioseg0, bioseg0) IS
110     'contains';
111    
112     CREATE FUNCTION bioseg0_contained(bioseg0, bioseg0)
113     RETURNS bool
114     AS '$libdir/bioseg0'
115     LANGUAGE C STRICT IMMUTABLE;
116    
117     COMMENT ON FUNCTION bioseg0_contained(bioseg0, bioseg0) IS
118     'contained in';
119    
120     CREATE FUNCTION bioseg0_overlap(bioseg0, bioseg0)
121     RETURNS bool
122     AS '$libdir/bioseg0'
123     LANGUAGE C STRICT IMMUTABLE;
124    
125     COMMENT ON FUNCTION bioseg0_overlap(bioseg0, bioseg0) IS
126     'overlaps';
127    
128     CREATE FUNCTION bioseg0_same(bioseg0, bioseg0)
129     RETURNS bool
130     AS '$libdir/bioseg0'
131     LANGUAGE C STRICT IMMUTABLE;
132    
133     COMMENT ON FUNCTION bioseg0_same(bioseg0, bioseg0) IS
134     'same as';
135    
136     CREATE FUNCTION bioseg0_different(bioseg0, bioseg0)
137     RETURNS bool
138     AS '$libdir/bioseg0'
139     LANGUAGE C STRICT IMMUTABLE;
140    
141     COMMENT ON FUNCTION bioseg0_different(bioseg0, bioseg0) IS
142     'different';
143    
144     -- support routines for indexing
145    
146     CREATE OR REPLACE FUNCTION bioseg0_cmp(bioseg0, bioseg0)
147     RETURNS int4
148     AS '$libdir/bioseg0'
149     LANGUAGE C STRICT IMMUTABLE;
150    
151     COMMENT ON FUNCTION bioseg0_cmp(bioseg0, bioseg0) IS 'btree comparison function';
152    
153     CREATE FUNCTION bioseg0_size(bioseg0)
154     RETURNS int4
155     AS '$libdir/bioseg0'
156     LANGUAGE C STRICT IMMUTABLE;
157    
158     -- miscellaneous
159    
160     CREATE FUNCTION bioseg0_upper(bioseg0)
161     RETURNS int4
162     AS '$libdir/bioseg0'
163     LANGUAGE C STRICT IMMUTABLE;
164    
165     CREATE FUNCTION bioseg0_lower(bioseg0)
166     RETURNS int4
167     AS '$libdir/bioseg0'
168     LANGUAGE C STRICT IMMUTABLE;
169    
170     CREATE FUNCTION bioseg0_sel(internal, oid, internal, integer)
171     RETURNS float
172     AS '$libdir/bioseg0'
173     LANGUAGE C STRICT IMMUTABLE;
174    
175     CREATE FUNCTION bioseg0_joinsel(internal, oid, internal, smallint)
176     RETURNS FLOAT
177     AS '$libdir/bioseg0'
178     LANGUAGE C STRICT IMMUTABLE;
179    
180     CREATE FUNCTION bioseg0_contsel(internal, oid, internal, integer)
181     RETURNS float
182     AS '$libdir/bioseg0'
183     LANGUAGE C STRICT IMMUTABLE;
184    
185     CREATE FUNCTION bioseg0_contjoinsel(internal, oid, internal, smallint)
186     RETURNS FLOAT
187     AS '$libdir/bioseg0'
188     LANGUAGE C STRICT IMMUTABLE;
189    
190    
191     --
192     -- OPERATORS
193     --
194    
195     CREATE OPERATOR < (
196     LEFTARG = bioseg0,
197     RIGHTARG = bioseg0,
198     PROCEDURE = bioseg0_lt,
199     COMMUTATOR = '>',
200     NEGATOR = '>=',
201     RESTRICT = scalarltsel,
202     JOIN = scalarltjoinsel
203     );
204    
205     CREATE OPERATOR <= (
206     LEFTARG = bioseg0,
207     RIGHTARG = bioseg0,
208     PROCEDURE = bioseg0_le,
209     COMMUTATOR = '>=',
210     NEGATOR = '>',
211     RESTRICT = scalarltsel,
212     JOIN = scalarltjoinsel
213     );
214    
215     CREATE OPERATOR > (
216     LEFTARG = bioseg0,
217     RIGHTARG = bioseg0,
218     PROCEDURE = bioseg0_gt,
219     COMMUTATOR = '<',
220     NEGATOR = '<=',
221     RESTRICT = scalargtsel,
222     JOIN = scalargtjoinsel
223     );
224    
225     CREATE OPERATOR >= (
226     LEFTARG = bioseg0,
227     RIGHTARG = bioseg0,
228     PROCEDURE = bioseg0_ge,
229     COMMUTATOR = '<=',
230     NEGATOR = '<',
231     RESTRICT = scalargtsel,
232     JOIN = scalargtjoinsel
233     );
234    
235     CREATE OPERATOR << (
236     LEFTARG = bioseg0,
237     RIGHTARG = bioseg0,
238     PROCEDURE = bioseg0_left,
239     COMMUTATOR = '>>',
240     RESTRICT = positionsel,
241     JOIN = positionjoinsel
242     );
243    
244     CREATE OPERATOR &< (
245     LEFTARG = bioseg0,
246     RIGHTARG = bioseg0,
247     PROCEDURE = bioseg0_over_left,
248     RESTRICT = positionsel,
249     JOIN = positionjoinsel
250     );
251    
252     CREATE OPERATOR && (
253     LEFTARG = bioseg0,
254     RIGHTARG = bioseg0,
255     PROCEDURE = bioseg0_overlap,
256     COMMUTATOR = '&&',
257     RESTRICT = bioseg0_sel,
258     JOIN = bioseg0_joinsel
259     );
260    
261     CREATE OPERATOR &> (
262     LEFTARG = bioseg0,
263     RIGHTARG = bioseg0,
264     PROCEDURE = bioseg0_over_right,
265     RESTRICT = positionsel,
266     JOIN = positionjoinsel
267     );
268    
269     CREATE OPERATOR >> (
270     LEFTARG = bioseg0,
271     RIGHTARG = bioseg0,
272     PROCEDURE = bioseg0_right,
273     COMMUTATOR = '<<',
274     RESTRICT = positionsel,
275     JOIN = positionjoinsel
276     );
277    
278     CREATE OPERATOR = (
279     LEFTARG = bioseg0,
280     RIGHTARG = bioseg0,
281     PROCEDURE = bioseg0_same,
282     COMMUTATOR = '=',
283     NEGATOR = '<>',
284     RESTRICT = eqsel,
285     JOIN = eqjoinsel,
286     MERGES
287     );
288    
289     CREATE OPERATOR <> (
290     LEFTARG = bioseg0,
291     RIGHTARG = bioseg0,
292     PROCEDURE = bioseg0_different,
293     COMMUTATOR = '<>',
294     NEGATOR = '=',
295     RESTRICT = neqsel,
296     JOIN = neqjoinsel
297     );
298    
299     CREATE OPERATOR @> (
300     LEFTARG = bioseg0,
301     RIGHTARG = bioseg0,
302     PROCEDURE = bioseg0_contains,
303     COMMUTATOR = '<@',
304     RESTRICT = bioseg0_contsel,
305     JOIN = bioseg0_contjoinsel
306     );
307    
308     CREATE OPERATOR <@ (
309     LEFTARG = bioseg0,
310     RIGHTARG = bioseg0,
311     PROCEDURE = bioseg0_contained,
312     COMMUTATOR = '@>',
313     RESTRICT = bioseg0_contsel,
314     JOIN = bioseg0_contjoinsel
315     );
316    
317    
318    
319     -- define the GiST support methods
320     CREATE FUNCTION bioseg0_gist_consistent(internal,bioseg0,int4)
321     RETURNS bool
322     AS '$libdir/bioseg0'
323 kmr 13 LANGUAGE C IMMUTABLE;
324 kmr 6
325     CREATE FUNCTION bioseg0_gist_compress(internal)
326     RETURNS internal
327     AS '$libdir/bioseg0'
328 kmr 13 LANGUAGE C IMMUTABLE;
329 kmr 6
330     CREATE FUNCTION bioseg0_gist_decompress(internal)
331     RETURNS internal
332     AS '$libdir/bioseg0'
333 kmr 13 LANGUAGE C IMMUTABLE;
334 kmr 6
335     CREATE FUNCTION bioseg0_gist_penalty(internal,internal,internal)
336     RETURNS internal
337     AS '$libdir/bioseg0'
338 kmr 13 LANGUAGE C STRICT IMMUTABLE;
339 kmr 6
340     CREATE FUNCTION bioseg0_gist_picksplit(internal, internal)
341     RETURNS internal
342     AS '$libdir/bioseg0'
343 kmr 13 LANGUAGE C IMMUTABLE;
344 kmr 6
345     CREATE FUNCTION bioseg0_gist_union(internal, internal)
346     RETURNS bioseg0
347     AS '$libdir/bioseg0'
348 kmr 13 LANGUAGE C IMMUTABLE;
349 kmr 6
350     CREATE FUNCTION bioseg0_gist_same(bioseg0, bioseg0, internal)
351     RETURNS internal
352     AS '$libdir/bioseg0'
353 kmr 13 LANGUAGE C IMMUTABLE;
354 kmr 6
355    
356     -- Create the operator classes for indexing
357    
358     CREATE OPERATOR CLASS bioseg0_ops
359     DEFAULT FOR TYPE bioseg0 USING btree AS
360     OPERATOR 1 < ,
361     OPERATOR 2 <= ,
362     OPERATOR 3 = ,
363     OPERATOR 4 >= ,
364     OPERATOR 5 > ,
365     FUNCTION 1 bioseg0_cmp(bioseg0, bioseg0);
366    
367     CREATE OPERATOR CLASS gist_bioseg0_ops
368     DEFAULT FOR TYPE bioseg0 USING gist
369     AS
370     OPERATOR 1 << ,
371     OPERATOR 2 &< ,
372     OPERATOR 3 && ,
373     OPERATOR 4 &> ,
374     OPERATOR 5 >> ,
375     OPERATOR 6 = ,
376     OPERATOR 7 @> ,
377     OPERATOR 8 <@ ,
378     FUNCTION 1 bioseg0_gist_consistent (internal, bioseg0, int4),
379     FUNCTION 2 bioseg0_gist_union (internal, internal),
380     FUNCTION 3 bioseg0_gist_compress (internal),
381     FUNCTION 4 bioseg0_gist_decompress (internal),
382     FUNCTION 5 bioseg0_gist_penalty (internal, internal, internal),
383     FUNCTION 6 bioseg0_gist_picksplit (internal, internal),
384     FUNCTION 7 bioseg0_gist_same (bioseg0, bioseg0, internal);