2002-07-31 01:34:37 +08:00
|
|
|
-- Adjust this setting to control where the objects get created.
|
|
|
|
SET search_path = public;
|
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
SET autocommit TO 'on';
|
|
|
|
|
2002-07-31 01:34:37 +08:00
|
|
|
-- create type of int4 key
|
2002-08-22 08:01:51 +08:00
|
|
|
CREATE FUNCTION int4key_in(cstring)
|
|
|
|
RETURNS int4key
|
2001-08-23 02:27:54 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-19 02:41:22 +08:00
|
|
|
LANGUAGE 'c' WITH (isstrict);
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-08-22 08:01:51 +08:00
|
|
|
CREATE FUNCTION int4key_out(int4key)
|
|
|
|
RETURNS cstring
|
2001-08-23 02:27:54 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-19 02:41:22 +08:00
|
|
|
LANGUAGE 'c' WITH (isstrict);
|
2001-08-23 02:27:54 +08:00
|
|
|
|
|
|
|
CREATE TYPE int4key (
|
2002-10-19 02:41:22 +08:00
|
|
|
INTERNALLENGTH = 8,
|
|
|
|
INPUT = int4key_in,
|
|
|
|
OUTPUT = int4key_out
|
2001-08-23 02:27:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- int4 ops
|
|
|
|
--
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- define the GiST support methods
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gint4_consistent(internal,int4,int2)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gint4_compress(internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION btree_decompress(internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gint4_penalty(internal,internal,internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C' WITH (isstrict);
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gint4_picksplit(internal, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gint4_union(bytea, internal)
|
|
|
|
RETURNS int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gint4_same(internal, internal, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-07-31 01:34:37 +08:00
|
|
|
-- Create the operator class
|
|
|
|
CREATE OPERATOR CLASS gist_int4_ops
|
2002-10-19 02:41:22 +08:00
|
|
|
DEFAULT FOR TYPE int4 USING gist
|
|
|
|
AS
|
2002-07-31 01:34:37 +08:00
|
|
|
OPERATOR 1 < ,
|
|
|
|
OPERATOR 2 <= ,
|
|
|
|
OPERATOR 3 = ,
|
|
|
|
OPERATOR 4 >= ,
|
|
|
|
OPERATOR 5 > ,
|
2002-08-22 08:01:51 +08:00
|
|
|
FUNCTION 1 gint4_consistent (internal, int4, int2),
|
|
|
|
FUNCTION 2 gint4_union (bytea, internal),
|
|
|
|
FUNCTION 3 gint4_compress (internal),
|
|
|
|
FUNCTION 4 btree_decompress (internal),
|
|
|
|
FUNCTION 5 gint4_penalty (internal, internal, internal),
|
|
|
|
FUNCTION 6 gint4_picksplit (internal, internal),
|
|
|
|
FUNCTION 7 gint4_same (internal, internal, internal),
|
2002-07-31 01:34:37 +08:00
|
|
|
STORAGE int4key;
|
2001-08-23 02:27:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- timestamp ops
|
|
|
|
--
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- create type of timestamp key
|
|
|
|
|
2002-08-22 08:01:51 +08:00
|
|
|
CREATE FUNCTION tskey_in(cstring)
|
|
|
|
RETURNS tskey
|
2001-08-23 02:27:54 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-19 02:41:22 +08:00
|
|
|
LANGUAGE 'c' WITH (isstrict);
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-08-22 08:01:51 +08:00
|
|
|
CREATE FUNCTION tskey_out(tskey)
|
|
|
|
RETURNS cstring
|
2001-08-23 02:27:54 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2002-10-19 02:41:22 +08:00
|
|
|
LANGUAGE 'c' WITH (isstrict);
|
2001-08-23 02:27:54 +08:00
|
|
|
|
|
|
|
CREATE TYPE tskey (
|
2002-10-19 02:41:22 +08:00
|
|
|
INTERNALLENGTH = 16,
|
|
|
|
INPUT = tskey_in,
|
|
|
|
OUTPUT = tskey_out
|
2001-08-23 02:27:54 +08:00
|
|
|
);
|
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gts_consistent(internal,timestamp,int2)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gts_compress(internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gts_penalty(internal,internal,internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C' WITH (isstrict);
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gts_picksplit(internal, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gts_union(bytea, internal)
|
|
|
|
RETURNS int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
CREATE FUNCTION gts_same(internal, internal, internal)
|
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE 'C';
|
2001-08-23 02:27:54 +08:00
|
|
|
|
2002-07-31 01:34:37 +08:00
|
|
|
-- Create the operator class
|
|
|
|
CREATE OPERATOR CLASS gist_timestamp_ops
|
2002-10-19 02:41:22 +08:00
|
|
|
DEFAULT FOR TYPE timestamp USING gist
|
|
|
|
AS
|
2002-07-31 01:34:37 +08:00
|
|
|
OPERATOR 1 < ,
|
|
|
|
OPERATOR 2 <= ,
|
|
|
|
OPERATOR 3 = ,
|
|
|
|
OPERATOR 4 >= ,
|
|
|
|
OPERATOR 5 > ,
|
2002-08-22 08:01:51 +08:00
|
|
|
FUNCTION 1 gts_consistent (internal, timestamp, int2),
|
|
|
|
FUNCTION 2 gts_union (bytea, internal),
|
|
|
|
FUNCTION 3 gts_compress (internal),
|
|
|
|
FUNCTION 4 btree_decompress (internal),
|
|
|
|
FUNCTION 5 gts_penalty (internal, internal, internal),
|
|
|
|
FUNCTION 6 gts_picksplit (internal, internal),
|
|
|
|
FUNCTION 7 gts_same (internal, internal, internal),
|
2002-07-31 01:34:37 +08:00
|
|
|
STORAGE tskey;
|