mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
65b6868b13
OPERATOR CLASS commands. Further tweaking of documentation for same.
120 lines
3.1 KiB
MySQL
120 lines
3.1 KiB
MySQL
begin transaction;
|
|
|
|
-- Adjust this setting to control where the objects get created.
|
|
SET search_path = public;
|
|
|
|
-- create type of int4 key
|
|
CREATE FUNCTION int4key_in(opaque)
|
|
RETURNS opaque
|
|
AS 'MODULE_PATHNAME'
|
|
LANGUAGE 'c' with (isstrict);
|
|
|
|
CREATE FUNCTION int4key_out(opaque)
|
|
RETURNS opaque
|
|
AS 'MODULE_PATHNAME'
|
|
LANGUAGE 'c' with (isstrict);
|
|
|
|
CREATE TYPE int4key (
|
|
internallength = 8,
|
|
input = int4key_in,
|
|
output = int4key_out
|
|
);
|
|
|
|
|
|
--
|
|
--
|
|
--
|
|
-- int4 ops
|
|
--
|
|
--
|
|
--
|
|
-- define the GiST support methods
|
|
create function gint4_consistent(opaque,int4,int2) returns bool as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gint4_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function btree_decompress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gint4_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with(isstrict);
|
|
|
|
create function gint4_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gint4_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gint4_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
|
|
|
|
-- Create the operator class
|
|
CREATE OPERATOR CLASS gist_int4_ops
|
|
DEFAULT FOR TYPE int4 USING gist AS
|
|
OPERATOR 1 < ,
|
|
OPERATOR 2 <= ,
|
|
OPERATOR 3 = ,
|
|
OPERATOR 4 >= ,
|
|
OPERATOR 5 > ,
|
|
FUNCTION 1 gint4_consistent (opaque, int4, int2),
|
|
FUNCTION 2 gint4_union (bytea, opaque),
|
|
FUNCTION 3 gint4_compress (opaque),
|
|
FUNCTION 4 btree_decompress (opaque),
|
|
FUNCTION 5 gint4_penalty (opaque, opaque, opaque),
|
|
FUNCTION 6 gint4_picksplit (opaque, opaque),
|
|
FUNCTION 7 gint4_same (opaque, opaque, opaque),
|
|
STORAGE int4key;
|
|
|
|
|
|
--
|
|
--
|
|
--
|
|
-- timestamp ops
|
|
--
|
|
--
|
|
--
|
|
-- create type of timestamp key
|
|
|
|
CREATE FUNCTION tskey_in(opaque)
|
|
RETURNS opaque
|
|
AS 'MODULE_PATHNAME'
|
|
LANGUAGE 'c' with (isstrict);
|
|
|
|
CREATE FUNCTION tskey_out(opaque)
|
|
RETURNS opaque
|
|
AS 'MODULE_PATHNAME'
|
|
LANGUAGE 'c' with (isstrict);
|
|
|
|
CREATE TYPE tskey (
|
|
internallength = 16,
|
|
input = tskey_in,
|
|
output = tskey_out
|
|
);
|
|
|
|
create function gts_consistent(opaque,timestamp,int2) returns bool as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gts_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gts_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with(isstrict);
|
|
|
|
create function gts_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gts_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' language 'C';
|
|
|
|
create function gts_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
|
|
|
|
-- Create the operator class
|
|
CREATE OPERATOR CLASS gist_timestamp_ops
|
|
DEFAULT FOR TYPE timestamp USING gist AS
|
|
OPERATOR 1 < ,
|
|
OPERATOR 2 <= ,
|
|
OPERATOR 3 = ,
|
|
OPERATOR 4 >= ,
|
|
OPERATOR 5 > ,
|
|
FUNCTION 1 gts_consistent (opaque, timestamp, int2),
|
|
FUNCTION 2 gts_union (bytea, opaque),
|
|
FUNCTION 3 gts_compress (opaque),
|
|
FUNCTION 4 btree_decompress (opaque),
|
|
FUNCTION 5 gts_penalty (opaque, opaque, opaque),
|
|
FUNCTION 6 gts_picksplit (opaque, opaque),
|
|
FUNCTION 7 gts_same (opaque, opaque, opaque),
|
|
STORAGE tskey;
|
|
|
|
|
|
end transaction;
|