Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / contrib / ltree / ltree.sql.in
blob056cdb8155a6c9b08bc82f3a748da054ee2708ec
1 /* $PostgreSQL$ */
3 -- Adjust this setting to control where the objects get created.
4 SET search_path = public;
6 CREATE OR REPLACE FUNCTION ltree_in(cstring)
7 RETURNS ltree
8 AS 'MODULE_PATHNAME'
9 LANGUAGE C STRICT;
11 CREATE OR REPLACE FUNCTION ltree_out(ltree)
12 RETURNS cstring
13 AS 'MODULE_PATHNAME'
14 LANGUAGE C STRICT;
16 CREATE TYPE ltree (
17 INTERNALLENGTH = -1,
18 INPUT = ltree_in,
19 OUTPUT = ltree_out,
20 STORAGE = extended
24 --Compare function for ltree
25 CREATE OR REPLACE FUNCTION ltree_cmp(ltree,ltree)
26 RETURNS int4
27 AS 'MODULE_PATHNAME'
28 LANGUAGE C STRICT IMMUTABLE;
30 CREATE OR REPLACE FUNCTION ltree_lt(ltree,ltree)
31 RETURNS bool
32 AS 'MODULE_PATHNAME'
33 LANGUAGE C STRICT IMMUTABLE;
35 CREATE OR REPLACE FUNCTION ltree_le(ltree,ltree)
36 RETURNS bool
37 AS 'MODULE_PATHNAME'
38 LANGUAGE C STRICT IMMUTABLE;
40 CREATE OR REPLACE FUNCTION ltree_eq(ltree,ltree)
41 RETURNS bool
42 AS 'MODULE_PATHNAME'
43 LANGUAGE C STRICT IMMUTABLE;
45 CREATE OR REPLACE FUNCTION ltree_ge(ltree,ltree)
46 RETURNS bool
47 AS 'MODULE_PATHNAME'
48 LANGUAGE C STRICT IMMUTABLE;
50 CREATE OR REPLACE FUNCTION ltree_gt(ltree,ltree)
51 RETURNS bool
52 AS 'MODULE_PATHNAME'
53 LANGUAGE C STRICT IMMUTABLE;
55 CREATE OR REPLACE FUNCTION ltree_ne(ltree,ltree)
56 RETURNS bool
57 AS 'MODULE_PATHNAME'
58 LANGUAGE C STRICT IMMUTABLE;
61 CREATE OPERATOR < (
62 LEFTARG = ltree,
63 RIGHTARG = ltree,
64 PROCEDURE = ltree_lt,
65 COMMUTATOR = '>',
66 NEGATOR = '>=',
67 RESTRICT = contsel,
68 JOIN = contjoinsel
71 CREATE OPERATOR <= (
72 LEFTARG = ltree,
73 RIGHTARG = ltree,
74 PROCEDURE = ltree_le,
75 COMMUTATOR = '>=',
76 NEGATOR = '>',
77 RESTRICT = contsel,
78 JOIN = contjoinsel
81 CREATE OPERATOR >= (
82 LEFTARG = ltree,
83 RIGHTARG = ltree,
84 PROCEDURE = ltree_ge,
85 COMMUTATOR = '<=',
86 NEGATOR = '<',
87 RESTRICT = contsel,
88 JOIN = contjoinsel
91 CREATE OPERATOR > (
92 LEFTARG = ltree,
93 RIGHTARG = ltree,
94 PROCEDURE = ltree_gt,
95 COMMUTATOR = '<',
96 NEGATOR = '<=',
97 RESTRICT = contsel,
98 JOIN = contjoinsel
101 CREATE OPERATOR = (
102 LEFTARG = ltree,
103 RIGHTARG = ltree,
104 PROCEDURE = ltree_eq,
105 COMMUTATOR = '=',
106 NEGATOR = '<>',
107 RESTRICT = eqsel,
108 JOIN = eqjoinsel,
109 SORT1 = '<',
110 SORT2 = '<'
113 CREATE OPERATOR <> (
114 LEFTARG = ltree,
115 RIGHTARG = ltree,
116 PROCEDURE = ltree_ne,
117 COMMUTATOR = '<>',
118 NEGATOR = '=',
119 RESTRICT = neqsel,
120 JOIN = neqjoinsel
123 --util functions
125 CREATE OR REPLACE FUNCTION subltree(ltree,int4,int4)
126 RETURNS ltree
127 AS 'MODULE_PATHNAME'
128 LANGUAGE C STRICT IMMUTABLE;
130 CREATE OR REPLACE FUNCTION subpath(ltree,int4,int4)
131 RETURNS ltree
132 AS 'MODULE_PATHNAME'
133 LANGUAGE C STRICT IMMUTABLE;
135 CREATE OR REPLACE FUNCTION subpath(ltree,int4)
136 RETURNS ltree
137 AS 'MODULE_PATHNAME'
138 LANGUAGE C STRICT IMMUTABLE;
140 CREATE OR REPLACE FUNCTION index(ltree,ltree)
141 RETURNS int4
142 AS 'MODULE_PATHNAME', 'ltree_index'
143 LANGUAGE C STRICT IMMUTABLE;
145 CREATE OR REPLACE FUNCTION index(ltree,ltree,int4)
146 RETURNS int4
147 AS 'MODULE_PATHNAME', 'ltree_index'
148 LANGUAGE C STRICT IMMUTABLE;
150 CREATE OR REPLACE FUNCTION nlevel(ltree)
151 RETURNS int4
152 AS 'MODULE_PATHNAME'
153 LANGUAGE C STRICT IMMUTABLE;
155 CREATE OR REPLACE FUNCTION ltree2text(ltree)
156 RETURNS text
157 AS 'MODULE_PATHNAME'
158 LANGUAGE C STRICT IMMUTABLE;
160 CREATE OR REPLACE FUNCTION text2ltree(text)
161 RETURNS ltree
162 AS 'MODULE_PATHNAME'
163 LANGUAGE C STRICT IMMUTABLE;
165 CREATE OR REPLACE FUNCTION lca(_ltree)
166 RETURNS ltree
167 AS 'MODULE_PATHNAME','_lca'
168 LANGUAGE C STRICT IMMUTABLE;
170 CREATE OR REPLACE FUNCTION lca(ltree,ltree)
171 RETURNS ltree
172 AS 'MODULE_PATHNAME'
173 LANGUAGE C STRICT IMMUTABLE;
175 CREATE OR REPLACE FUNCTION lca(ltree,ltree,ltree)
176 RETURNS ltree
177 AS 'MODULE_PATHNAME'
178 LANGUAGE C STRICT IMMUTABLE;
180 CREATE OR REPLACE FUNCTION lca(ltree,ltree,ltree,ltree)
181 RETURNS ltree
182 AS 'MODULE_PATHNAME'
183 LANGUAGE C STRICT IMMUTABLE;
185 CREATE OR REPLACE FUNCTION lca(ltree,ltree,ltree,ltree,ltree)
186 RETURNS ltree
187 AS 'MODULE_PATHNAME'
188 LANGUAGE C STRICT IMMUTABLE;
190 CREATE OR REPLACE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree)
191 RETURNS ltree
192 AS 'MODULE_PATHNAME'
193 LANGUAGE C STRICT IMMUTABLE;
195 CREATE OR REPLACE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree)
196 RETURNS ltree
197 AS 'MODULE_PATHNAME'
198 LANGUAGE C STRICT IMMUTABLE;
200 CREATE OR REPLACE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree,ltree)
201 RETURNS ltree
202 AS 'MODULE_PATHNAME'
203 LANGUAGE C STRICT IMMUTABLE;
205 CREATE OR REPLACE FUNCTION ltree_isparent(ltree,ltree)
206 RETURNS bool
207 AS 'MODULE_PATHNAME'
208 LANGUAGE C STRICT IMMUTABLE;
210 CREATE OR REPLACE FUNCTION ltree_risparent(ltree,ltree)
211 RETURNS bool
212 AS 'MODULE_PATHNAME'
213 LANGUAGE C STRICT IMMUTABLE;
215 CREATE OR REPLACE FUNCTION ltree_addltree(ltree,ltree)
216 RETURNS ltree
217 AS 'MODULE_PATHNAME'
218 LANGUAGE C STRICT IMMUTABLE;
220 CREATE OR REPLACE FUNCTION ltree_addtext(ltree,text)
221 RETURNS ltree
222 AS 'MODULE_PATHNAME'
223 LANGUAGE C STRICT IMMUTABLE;
225 CREATE OR REPLACE FUNCTION ltree_textadd(text,ltree)
226 RETURNS ltree
227 AS 'MODULE_PATHNAME'
228 LANGUAGE C STRICT IMMUTABLE;
230 CREATE OR REPLACE FUNCTION ltreeparentsel(internal, oid, internal, integer)
231 RETURNS float8
232 AS 'MODULE_PATHNAME'
233 LANGUAGE C STRICT IMMUTABLE;
235 CREATE OPERATOR @> (
236 LEFTARG = ltree,
237 RIGHTARG = ltree,
238 PROCEDURE = ltree_isparent,
239 COMMUTATOR = '<@',
240 RESTRICT = ltreeparentsel,
241 JOIN = contjoinsel
244 CREATE OPERATOR ^@> (
245 LEFTARG = ltree,
246 RIGHTARG = ltree,
247 PROCEDURE = ltree_isparent,
248 COMMUTATOR = '^<@',
249 RESTRICT = contsel,
250 JOIN = contjoinsel
253 CREATE OPERATOR <@ (
254 LEFTARG = ltree,
255 RIGHTARG = ltree,
256 PROCEDURE = ltree_risparent,
257 COMMUTATOR = '@>',
258 RESTRICT = ltreeparentsel,
259 JOIN = contjoinsel
262 CREATE OPERATOR ^<@ (
263 LEFTARG = ltree,
264 RIGHTARG = ltree,
265 PROCEDURE = ltree_risparent,
266 COMMUTATOR = '^@>',
267 RESTRICT = contsel,
268 JOIN = contjoinsel
271 CREATE OPERATOR || (
272 LEFTARG = ltree,
273 RIGHTARG = ltree,
274 PROCEDURE = ltree_addltree
277 CREATE OPERATOR || (
278 LEFTARG = ltree,
279 RIGHTARG = text,
280 PROCEDURE = ltree_addtext
283 CREATE OPERATOR || (
284 LEFTARG = text,
285 RIGHTARG = ltree,
286 PROCEDURE = ltree_textadd
290 -- B-tree support
292 CREATE OPERATOR CLASS ltree_ops
293 DEFAULT FOR TYPE ltree USING btree AS
294 OPERATOR 1 < ,
295 OPERATOR 2 <= ,
296 OPERATOR 3 = ,
297 OPERATOR 4 >= ,
298 OPERATOR 5 > ,
299 FUNCTION 1 ltree_cmp(ltree, ltree);
302 --lquery type
303 CREATE OR REPLACE FUNCTION lquery_in(cstring)
304 RETURNS lquery
305 AS 'MODULE_PATHNAME'
306 LANGUAGE C STRICT;
308 CREATE OR REPLACE FUNCTION lquery_out(lquery)
309 RETURNS cstring
310 AS 'MODULE_PATHNAME'
311 LANGUAGE C STRICT;
313 CREATE TYPE lquery (
314 INTERNALLENGTH = -1,
315 INPUT = lquery_in,
316 OUTPUT = lquery_out,
317 STORAGE = extended
320 CREATE OR REPLACE FUNCTION ltq_regex(ltree,lquery)
321 RETURNS bool
322 AS 'MODULE_PATHNAME'
323 LANGUAGE C STRICT IMMUTABLE;
325 CREATE OR REPLACE FUNCTION ltq_rregex(lquery,ltree)
326 RETURNS bool
327 AS 'MODULE_PATHNAME'
328 LANGUAGE C STRICT IMMUTABLE;
330 CREATE OPERATOR ~ (
331 LEFTARG = ltree,
332 RIGHTARG = lquery,
333 PROCEDURE = ltq_regex,
334 COMMUTATOR = '~',
335 RESTRICT = contsel,
336 JOIN = contjoinsel
339 CREATE OPERATOR ~ (
340 LEFTARG = lquery,
341 RIGHTARG = ltree,
342 PROCEDURE = ltq_rregex,
343 COMMUTATOR = '~',
344 RESTRICT = contsel,
345 JOIN = contjoinsel
348 --not-indexed
349 CREATE OPERATOR ^~ (
350 LEFTARG = ltree,
351 RIGHTARG = lquery,
352 PROCEDURE = ltq_regex,
353 COMMUTATOR = '^~',
354 RESTRICT = contsel,
355 JOIN = contjoinsel
358 CREATE OPERATOR ^~ (
359 LEFTARG = lquery,
360 RIGHTARG = ltree,
361 PROCEDURE = ltq_rregex,
362 COMMUTATOR = '^~',
363 RESTRICT = contsel,
364 JOIN = contjoinsel
367 CREATE OR REPLACE FUNCTION lt_q_regex(ltree,_lquery)
368 RETURNS bool
369 AS 'MODULE_PATHNAME'
370 LANGUAGE C STRICT IMMUTABLE;
372 CREATE OR REPLACE FUNCTION lt_q_rregex(_lquery,ltree)
373 RETURNS bool
374 AS 'MODULE_PATHNAME'
375 LANGUAGE C STRICT IMMUTABLE;
377 CREATE OPERATOR ? (
378 LEFTARG = ltree,
379 RIGHTARG = _lquery,
380 PROCEDURE = lt_q_regex,
381 COMMUTATOR = '?',
382 RESTRICT = contsel,
383 JOIN = contjoinsel
386 CREATE OPERATOR ? (
387 LEFTARG = _lquery,
388 RIGHTARG = ltree,
389 PROCEDURE = lt_q_rregex,
390 COMMUTATOR = '?',
391 RESTRICT = contsel,
392 JOIN = contjoinsel
395 --not-indexed
396 CREATE OPERATOR ^? (
397 LEFTARG = ltree,
398 RIGHTARG = _lquery,
399 PROCEDURE = lt_q_regex,
400 COMMUTATOR = '^?',
401 RESTRICT = contsel,
402 JOIN = contjoinsel
405 CREATE OPERATOR ^? (
406 LEFTARG = _lquery,
407 RIGHTARG = ltree,
408 PROCEDURE = lt_q_rregex,
409 COMMUTATOR = '^?',
410 RESTRICT = contsel,
411 JOIN = contjoinsel
414 CREATE OR REPLACE FUNCTION ltxtq_in(cstring)
415 RETURNS ltxtquery
416 AS 'MODULE_PATHNAME'
417 LANGUAGE C STRICT;
419 CREATE OR REPLACE FUNCTION ltxtq_out(ltxtquery)
420 RETURNS cstring
421 AS 'MODULE_PATHNAME'
422 LANGUAGE C STRICT;
424 CREATE TYPE ltxtquery (
425 INTERNALLENGTH = -1,
426 INPUT = ltxtq_in,
427 OUTPUT = ltxtq_out,
428 STORAGE = extended
431 -- operations WITH ltxtquery
433 CREATE OR REPLACE FUNCTION ltxtq_exec(ltree, ltxtquery)
434 RETURNS bool
435 AS 'MODULE_PATHNAME'
436 LANGUAGE C STRICT IMMUTABLE;
438 CREATE OR REPLACE FUNCTION ltxtq_rexec(ltxtquery, ltree)
439 RETURNS bool
440 AS 'MODULE_PATHNAME'
441 LANGUAGE C STRICT IMMUTABLE;
443 CREATE OPERATOR @ (
444 LEFTARG = ltree,
445 RIGHTARG = ltxtquery,
446 PROCEDURE = ltxtq_exec,
447 COMMUTATOR = '@',
448 RESTRICT = contsel,
449 JOIN = contjoinsel
452 CREATE OPERATOR @ (
453 LEFTARG = ltxtquery,
454 RIGHTARG = ltree,
455 PROCEDURE = ltxtq_rexec,
456 COMMUTATOR = '@',
457 RESTRICT = contsel,
458 JOIN = contjoinsel
461 --not-indexed
462 CREATE OPERATOR ^@ (
463 LEFTARG = ltree,
464 RIGHTARG = ltxtquery,
465 PROCEDURE = ltxtq_exec,
466 COMMUTATOR = '^@',
467 RESTRICT = contsel,
468 JOIN = contjoinsel
471 CREATE OPERATOR ^@ (
472 LEFTARG = ltxtquery,
473 RIGHTARG = ltree,
474 PROCEDURE = ltxtq_rexec,
475 COMMUTATOR = '^@',
476 RESTRICT = contsel,
477 JOIN = contjoinsel
480 --GiST support for ltree
481 CREATE OR REPLACE FUNCTION ltree_gist_in(cstring)
482 RETURNS ltree_gist
483 AS 'MODULE_PATHNAME'
484 LANGUAGE C STRICT;
486 CREATE OR REPLACE FUNCTION ltree_gist_out(ltree_gist)
487 RETURNS cstring
488 AS 'MODULE_PATHNAME'
489 LANGUAGE C STRICT;
491 CREATE TYPE ltree_gist (
492 internallength = -1,
493 input = ltree_gist_in,
494 output = ltree_gist_out,
495 storage = plain
499 CREATE OR REPLACE FUNCTION ltree_consistent(internal,internal,int2,oid,internal)
500 RETURNS bool as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
502 CREATE OR REPLACE FUNCTION ltree_compress(internal)
503 RETURNS internal as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
505 CREATE OR REPLACE FUNCTION ltree_decompress(internal)
506 RETURNS internal as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
508 CREATE OR REPLACE FUNCTION ltree_penalty(internal,internal,internal)
509 RETURNS internal as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
511 CREATE OR REPLACE FUNCTION ltree_picksplit(internal, internal)
512 RETURNS internal as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
514 CREATE OR REPLACE FUNCTION ltree_union(internal, internal)
515 RETURNS int4 as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
517 CREATE OR REPLACE FUNCTION ltree_same(internal, internal, internal)
518 RETURNS internal as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
520 CREATE OPERATOR CLASS gist_ltree_ops
521 DEFAULT FOR TYPE ltree USING gist AS
522 OPERATOR 1 < ,
523 OPERATOR 2 <= ,
524 OPERATOR 3 = ,
525 OPERATOR 4 >= ,
526 OPERATOR 5 > ,
527 OPERATOR 10 @> ,
528 OPERATOR 11 <@ ,
529 OPERATOR 12 ~ (ltree, lquery) ,
530 OPERATOR 13 ~ (lquery, ltree) ,
531 OPERATOR 14 @ (ltree, ltxtquery) ,
532 OPERATOR 15 @ (ltxtquery, ltree) ,
533 OPERATOR 16 ? (ltree, _lquery) ,
534 OPERATOR 17 ? (_lquery, ltree) ,
535 FUNCTION 1 ltree_consistent (internal, internal, int2, oid, internal),
536 FUNCTION 2 ltree_union (internal, internal),
537 FUNCTION 3 ltree_compress (internal),
538 FUNCTION 4 ltree_decompress (internal),
539 FUNCTION 5 ltree_penalty (internal, internal, internal),
540 FUNCTION 6 ltree_picksplit (internal, internal),
541 FUNCTION 7 ltree_same (internal, internal, internal),
542 STORAGE ltree_gist;
545 -- arrays of ltree
547 CREATE OR REPLACE FUNCTION _ltree_isparent(_ltree,ltree)
548 RETURNS bool
549 AS 'MODULE_PATHNAME'
550 LANGUAGE C STRICT IMMUTABLE;
552 CREATE OR REPLACE FUNCTION _ltree_r_isparent(ltree,_ltree)
553 RETURNS bool
554 AS 'MODULE_PATHNAME'
555 LANGUAGE C STRICT IMMUTABLE;
557 CREATE OR REPLACE FUNCTION _ltree_risparent(_ltree,ltree)
558 RETURNS bool
559 AS 'MODULE_PATHNAME'
560 LANGUAGE C STRICT IMMUTABLE;
562 CREATE OR REPLACE FUNCTION _ltree_r_risparent(ltree,_ltree)
563 RETURNS bool
564 AS 'MODULE_PATHNAME'
565 LANGUAGE C STRICT IMMUTABLE;
567 CREATE OR REPLACE FUNCTION _ltq_regex(_ltree,lquery)
568 RETURNS bool
569 AS 'MODULE_PATHNAME'
570 LANGUAGE C STRICT IMMUTABLE;
572 CREATE OR REPLACE FUNCTION _ltq_rregex(lquery,_ltree)
573 RETURNS bool
574 AS 'MODULE_PATHNAME'
575 LANGUAGE C STRICT IMMUTABLE;
577 CREATE OR REPLACE FUNCTION _lt_q_regex(_ltree,_lquery)
578 RETURNS bool
579 AS 'MODULE_PATHNAME'
580 LANGUAGE C STRICT IMMUTABLE;
582 CREATE OR REPLACE FUNCTION _lt_q_rregex(_lquery,_ltree)
583 RETURNS bool
584 AS 'MODULE_PATHNAME'
585 LANGUAGE C STRICT IMMUTABLE;
587 CREATE OR REPLACE FUNCTION _ltxtq_exec(_ltree, ltxtquery)
588 RETURNS bool
589 AS 'MODULE_PATHNAME'
590 LANGUAGE C STRICT IMMUTABLE;
592 CREATE OR REPLACE FUNCTION _ltxtq_rexec(ltxtquery, _ltree)
593 RETURNS bool
594 AS 'MODULE_PATHNAME'
595 LANGUAGE C STRICT IMMUTABLE;
597 CREATE OPERATOR @> (
598 LEFTARG = _ltree,
599 RIGHTARG = ltree,
600 PROCEDURE = _ltree_isparent,
601 COMMUTATOR = '<@',
602 RESTRICT = contsel,
603 JOIN = contjoinsel
606 CREATE OPERATOR <@ (
607 LEFTARG = ltree,
608 RIGHTARG = _ltree,
609 PROCEDURE = _ltree_r_isparent,
610 COMMUTATOR = '@>',
611 RESTRICT = contsel,
612 JOIN = contjoinsel
615 CREATE OPERATOR <@ (
616 LEFTARG = _ltree,
617 RIGHTARG = ltree,
618 PROCEDURE = _ltree_risparent,
619 COMMUTATOR = '@>',
620 RESTRICT = contsel,
621 JOIN = contjoinsel
624 CREATE OPERATOR @> (
625 LEFTARG = ltree,
626 RIGHTARG = _ltree,
627 PROCEDURE = _ltree_r_risparent,
628 COMMUTATOR = '<@',
629 RESTRICT = contsel,
630 JOIN = contjoinsel
633 CREATE OPERATOR ~ (
634 LEFTARG = _ltree,
635 RIGHTARG = lquery,
636 PROCEDURE = _ltq_regex,
637 COMMUTATOR = '~',
638 RESTRICT = contsel,
639 JOIN = contjoinsel
642 CREATE OPERATOR ~ (
643 LEFTARG = lquery,
644 RIGHTARG = _ltree,
645 PROCEDURE = _ltq_rregex,
646 COMMUTATOR = '~',
647 RESTRICT = contsel,
648 JOIN = contjoinsel
651 CREATE OPERATOR ? (
652 LEFTARG = _ltree,
653 RIGHTARG = _lquery,
654 PROCEDURE = _lt_q_regex,
655 COMMUTATOR = '?',
656 RESTRICT = contsel,
657 JOIN = contjoinsel
660 CREATE OPERATOR ? (
661 LEFTARG = _lquery,
662 RIGHTARG = _ltree,
663 PROCEDURE = _lt_q_rregex,
664 COMMUTATOR = '?',
665 RESTRICT = contsel,
666 JOIN = contjoinsel
669 CREATE OPERATOR @ (
670 LEFTARG = _ltree,
671 RIGHTARG = ltxtquery,
672 PROCEDURE = _ltxtq_exec,
673 COMMUTATOR = '@',
674 RESTRICT = contsel,
675 JOIN = contjoinsel
678 CREATE OPERATOR @ (
679 LEFTARG = ltxtquery,
680 RIGHTARG = _ltree,
681 PROCEDURE = _ltxtq_rexec,
682 COMMUTATOR = '@',
683 RESTRICT = contsel,
684 JOIN = contjoinsel
688 --not indexed
689 CREATE OPERATOR ^@> (
690 LEFTARG = _ltree,
691 RIGHTARG = ltree,
692 PROCEDURE = _ltree_isparent,
693 COMMUTATOR = '^<@',
694 RESTRICT = contsel,
695 JOIN = contjoinsel
698 CREATE OPERATOR ^<@ (
699 LEFTARG = ltree,
700 RIGHTARG = _ltree,
701 PROCEDURE = _ltree_r_isparent,
702 COMMUTATOR = '^@>',
703 RESTRICT = contsel,
704 JOIN = contjoinsel
707 CREATE OPERATOR ^<@ (
708 LEFTARG = _ltree,
709 RIGHTARG = ltree,
710 PROCEDURE = _ltree_risparent,
711 COMMUTATOR = '^@>',
712 RESTRICT = contsel,
713 JOIN = contjoinsel
716 CREATE OPERATOR ^@> (
717 LEFTARG = ltree,
718 RIGHTARG = _ltree,
719 PROCEDURE = _ltree_r_risparent,
720 COMMUTATOR = '^<@',
721 RESTRICT = contsel,
722 JOIN = contjoinsel
725 CREATE OPERATOR ^~ (
726 LEFTARG = _ltree,
727 RIGHTARG = lquery,
728 PROCEDURE = _ltq_regex,
729 COMMUTATOR = '^~',
730 RESTRICT = contsel,
731 JOIN = contjoinsel
734 CREATE OPERATOR ^~ (
735 LEFTARG = lquery,
736 RIGHTARG = _ltree,
737 PROCEDURE = _ltq_rregex,
738 COMMUTATOR = '^~',
739 RESTRICT = contsel,
740 JOIN = contjoinsel
743 CREATE OPERATOR ^? (
744 LEFTARG = _ltree,
745 RIGHTARG = _lquery,
746 PROCEDURE = _lt_q_regex,
747 COMMUTATOR = '^?',
748 RESTRICT = contsel,
749 JOIN = contjoinsel
752 CREATE OPERATOR ^? (
753 LEFTARG = _lquery,
754 RIGHTARG = _ltree,
755 PROCEDURE = _lt_q_rregex,
756 COMMUTATOR = '^?',
757 RESTRICT = contsel,
758 JOIN = contjoinsel
761 CREATE OPERATOR ^@ (
762 LEFTARG = _ltree,
763 RIGHTARG = ltxtquery,
764 PROCEDURE = _ltxtq_exec,
765 COMMUTATOR = '^@',
766 RESTRICT = contsel,
767 JOIN = contjoinsel
770 CREATE OPERATOR ^@ (
771 LEFTARG = ltxtquery,
772 RIGHTARG = _ltree,
773 PROCEDURE = _ltxtq_rexec,
774 COMMUTATOR = '^@',
775 RESTRICT = contsel,
776 JOIN = contjoinsel
779 --extractors
780 CREATE OR REPLACE FUNCTION _ltree_extract_isparent(_ltree,ltree)
781 RETURNS ltree
782 AS 'MODULE_PATHNAME'
783 LANGUAGE C STRICT IMMUTABLE;
785 CREATE OPERATOR ?@> (
786 LEFTARG = _ltree,
787 RIGHTARG = ltree,
788 PROCEDURE = _ltree_extract_isparent
791 CREATE OR REPLACE FUNCTION _ltree_extract_risparent(_ltree,ltree)
792 RETURNS ltree
793 AS 'MODULE_PATHNAME'
794 LANGUAGE C STRICT IMMUTABLE;
796 CREATE OPERATOR ?<@ (
797 LEFTARG = _ltree,
798 RIGHTARG = ltree,
799 PROCEDURE = _ltree_extract_risparent
802 CREATE OR REPLACE FUNCTION _ltq_extract_regex(_ltree,lquery)
803 RETURNS ltree
804 AS 'MODULE_PATHNAME'
805 LANGUAGE C STRICT IMMUTABLE;
807 CREATE OPERATOR ?~ (
808 LEFTARG = _ltree,
809 RIGHTARG = lquery,
810 PROCEDURE = _ltq_extract_regex
813 CREATE OR REPLACE FUNCTION _ltxtq_extract_exec(_ltree,ltxtquery)
814 RETURNS ltree
815 AS 'MODULE_PATHNAME'
816 LANGUAGE C STRICT IMMUTABLE;
818 CREATE OPERATOR ?@ (
819 LEFTARG = _ltree,
820 RIGHTARG = ltxtquery,
821 PROCEDURE = _ltxtq_extract_exec
824 --GiST support for ltree[]
825 CREATE OR REPLACE FUNCTION _ltree_consistent(internal,internal,int2,oid,internal)
826 RETURNS bool
827 AS 'MODULE_PATHNAME'
828 LANGUAGE C IMMUTABLE STRICT;
830 CREATE OR REPLACE FUNCTION _ltree_compress(internal)
831 RETURNS internal
832 AS 'MODULE_PATHNAME'
833 LANGUAGE C IMMUTABLE STRICT;
835 CREATE OR REPLACE FUNCTION _ltree_penalty(internal,internal,internal)
836 RETURNS internal
837 AS 'MODULE_PATHNAME'
838 LANGUAGE C IMMUTABLE STRICT;
840 CREATE OR REPLACE FUNCTION _ltree_picksplit(internal, internal)
841 RETURNS internal
842 AS 'MODULE_PATHNAME'
843 LANGUAGE C IMMUTABLE STRICT;
845 CREATE OR REPLACE FUNCTION _ltree_union(internal, internal)
846 RETURNS int4
847 AS 'MODULE_PATHNAME'
848 LANGUAGE C IMMUTABLE STRICT;
850 CREATE OR REPLACE FUNCTION _ltree_same(internal, internal, internal)
851 RETURNS internal
852 AS 'MODULE_PATHNAME'
853 LANGUAGE C IMMUTABLE STRICT;
855 CREATE OPERATOR CLASS gist__ltree_ops
856 DEFAULT FOR TYPE _ltree USING gist AS
857 OPERATOR 10 <@ (_ltree, ltree),
858 OPERATOR 11 @> (ltree, _ltree),
859 OPERATOR 12 ~ (_ltree, lquery),
860 OPERATOR 13 ~ (lquery, _ltree),
861 OPERATOR 14 @ (_ltree, ltxtquery),
862 OPERATOR 15 @ (ltxtquery, _ltree),
863 OPERATOR 16 ? (_ltree, _lquery),
864 OPERATOR 17 ? (_lquery, _ltree),
865 FUNCTION 1 _ltree_consistent (internal, internal, int2, oid, internal),
866 FUNCTION 2 _ltree_union (internal, internal),
867 FUNCTION 3 _ltree_compress (internal),
868 FUNCTION 4 ltree_decompress (internal),
869 FUNCTION 5 _ltree_penalty (internal, internal, internal),
870 FUNCTION 6 _ltree_picksplit (internal, internal),
871 FUNCTION 7 _ltree_same (internal, internal, internal),
872 STORAGE ltree_gist;