LANGUAGE 'c' with (isstrict);
-------- 7.2 GiST support functions
-create function ggeometry_consistent(opaque,GEOMETRY,int4) returns bool
+create function ggeometry_consistent(internal,GEOMETRY,int4) returns bool
as '@MODULE_FILENAME@' language 'C';
-create function ggeometry_compress(opaque) returns opaque
+create function ggeometry_compress(internal) returns internal
as '@MODULE_FILENAME@' language 'C';
-create function gbox_penalty(opaque,opaque,opaque) returns opaque
+create function gbox_penalty(internal,internal,internal) returns internal
as '@MODULE_FILENAME@' language 'C';
-create function gbox_picksplit(opaque, opaque) returns opaque
+create function gbox_picksplit(internal, internal) returns internal
as '@MODULE_FILENAME@' language 'C';
-create function gbox_union(bytea, opaque) returns opaque
+create function gbox_union(bytea, internal) returns internal
as '@MODULE_FILENAME@' language 'C';
-create function gbox_same(box, box, opaque) returns opaque
+create function gbox_same(box, box, internal) returns internal
as '@MODULE_FILENAME@' language 'C';
-create function rtree_decompress(opaque) returns opaque
+create function rtree_decompress(internal) returns internal
as '@MODULE_FILENAME@' language 'C';
--------------------------
create function postgis_gist_sel (internal, oid, internal, int4) returns float8
RESTRICT = eqsel, JOIN = eqjoinsel
);
-
-
CREATE OPERATOR @ (
LEFTARG = GEOMETRY, RIGHTARG = GEOMETRY, PROCEDURE = geometry_contained,
COMMUTATOR = '@',
RESTRICT = contsel, JOIN = contjoinsel
);
-
CREATE OPERATOR ~ (
LEFTARG = GEOMETRY, RIGHTARG = GEOMETRY, PROCEDURE = geometry_contain,
COMMUTATOR = '@',
RESTRICT = contsel, JOIN = contjoinsel
);
-
-
-
---- old way = insert into pg_opclass values ('gist_geometry_ops');
-
-INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
- VALUES (
- (SELECT oid FROM pg_am WHERE amname = 'gist'),
- 'gist_geometry_ops',
- (SELECT oid FROM pg_type WHERE typname = 'geometry'),
- true,
- (SELECT oid FROM pg_type WHERE typname = 'box'));
-
---- drop table rt_ops_tmp;
-
-SELECT o.oid AS opoid, o.oprname
-INTO TABLE rt_ops_tmp
-FROM pg_operator o, pg_type t
-WHERE o.oprleft = t.oid
- and t.typname = 'geometry';
-
--- poly_left
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 1, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '<<';
-
--- poly_overleft
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 2, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '&<';
-
--- poly_overlap
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 3, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '&&';
-
--- poly_overright
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 4, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '&>';
-
--- poly_right
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 5, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '>>';
-
--- poly_same
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 6, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '~=';
-
--- poly_contains
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 7, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '~';
-
--- poly_contained
-INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
- SELECT opcl.oid, 8, true, c.opoid
- FROM pg_opclass opcl, rt_ops_tmp c
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and c.oprname = '@';
-
-DROP table rt_ops_tmp;
-
--- add the entries to amproc for the support methods
--- note the amprocnum numbers associated with each are specific!
-INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
- SELECT opcl.oid, 1, pro.oid
- FROM pg_opclass opcl, pg_proc pro
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and proname = 'ggeometry_consistent';
-
-INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
- SELECT opcl.oid, 2, pro.oid
- FROM pg_opclass opcl, pg_proc pro
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and proname = 'gbox_union';
-
-INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
- SELECT opcl.oid, 3, pro.oid
- FROM pg_opclass opcl, pg_proc pro
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and proname = 'ggeometry_compress';
-
-INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
- SELECT opcl.oid, 4, pro.oid
- FROM pg_opclass opcl, pg_proc pro
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and proname = 'rtree_decompress';
-
-INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
- SELECT opcl.oid, 5, pro.oid
- FROM pg_opclass opcl, pg_proc pro
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and proname = 'gbox_penalty';
-
-INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
- SELECT opcl.oid, 6, pro.oid
- FROM pg_opclass opcl, pg_proc pro
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and proname = 'gbox_picksplit';
-
-INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
- SELECT opcl.oid, 7, pro.oid
- FROM pg_opclass opcl, pg_proc pro
- WHERE
- opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
- and opcname = 'gist_geometry_ops'
- and proname = 'gbox_same';
+---------Create opclass
+
+CREATE OPERATOR CLASS gist_geometry_ops
+ DEFAULT FOR TYPE geometry USING gist AS
+ OPERATOR 1 << ,
+ OPERATOR 2 &< ,
+ OPERATOR 3 && ,
+ OPERATOR 4 &> ,
+ OPERATOR 5 >> ,
+ OPERATOR 6 = ,
+ OPERATOR 7 @ ,
+ OPERATOR 8 ~ ,
+ FUNCTION 1 ggeometry_consistent (internal, geometry, int4),
+ FUNCTION 2 gbox_union (bytea, internal),
+ FUNCTION 3 ggeometry_compress (internal),
+ FUNCTION 4 rtree_decompress (internal),
+ FUNCTION 5 gbox_penalty (internal, internal, internal),
+ FUNCTION 6 gbox_picksplit (internal, internal),
+ FUNCTION 7 gbox_same (box, box, internal);
END TRANSACTION;