--- uuid.sql.in 2006/01/13 06:44:34 1.3
+++ uuid.sql.in 2006/05/11 18:32:07 1.4
@@ -33,16 +33,35 @@
SET search_path TO public;
-DROP FUNCTION uuid_in(CSTRING) CASCADE;
-DROP FUNCTION uuid_out(uuid) CASCADE;
-DROP FUNCTION uuid_recv(INTERNAL) CASCADE;
-DROP FUNCTION uuid_send(uuid) CASCADE;
-DROP TYPE uuid CASCADE;
-DROP FUNCTION uuid(uuid) CASCADE;
-DROP FUNCTION uuid_eq(uuid) CASCADE;
-DROP FUNCTION uuid_ne(uuid) CASCADE;
-DROP OPERATOR =(uuid,uuid) CASCADE;
-DROP OPERATOR <>(uuid,uuid) CASCADE;
+DROP FUNCTION uuid_in(CSTRING) CASCADE;
+DROP FUNCTION uuid_out(uuid) CASCADE;
+DROP FUNCTION uuid_recv(INTERNAL) CASCADE;
+DROP FUNCTION uuid_send(uuid) CASCADE;
+DROP TYPE uuid CASCADE;
+DROP CAST (CSTRING AS uuid) CASCADE;
+DROP CAST (uuid AS CSTRING) CASCADE;
+
+DROP FUNCTION uuid(CSTRING) CASCADE;
+DROP FUNCTION uuid(INTEGER) CASCADE;
+DROP FUNCTION uuid(INTEGER, CSTRING, CSTRING) CASCADE;
+
+DROP FUNCTION uuid_eq(uuid) CASCADE;
+DROP FUNCTION uuid_ne(uuid) CASCADE;
+DROP FUNCTION uuid_lt(uuid, uuid) CASCADE;
+DROP FUNCTION uuid_gt(uuid, uuid) CASCADE;
+DROP FUNCTION uuid_le(uuid, uuid) CASCADE;
+DROP FUNCTION uuid_ge(uuid, uuid) CASCADE;
+DROP OPERATOR =(uuid,uuid) CASCADE;
+DROP OPERATOR <>(uuid,uuid) CASCADE;
+DROP OPERATOR <(uuid,uuid) CASCADE;
+DROP OPERATOR >(uuid,uuid) CASCADE;
+DROP OPERATOR <=(uuid,uuid) CASCADE;
+DROP OPERATOR >=(uuid,uuid) CASCADE;
+
+DROP FUNCTION uuid_hash(uuid) CASCADE;
+DROP FUNCTION uuid_cmp(uuid, uuid) CASCADE;
+DROP OPERATOR CLASS uuid_ops USING hash CASCADE;
+DROP OPERATOR CLASS uuid_ops USING btree CASCADE;
BEGIN;
@@ -83,6 +102,12 @@
COMMENT ON TYPE uuid
IS 'UUID type';
+CREATE CAST (CSTRING AS uuid)
+ WITH FUNCTION uuid_in(CSTRING) AS ASSIGNMENT;
+
+CREATE CAST (uuid AS CSTRING)
+ WITH FUNCTION uuid_out(uuid) AS ASSIGNMENT;
+
--
-- the UUID constructor function
--
@@ -116,6 +141,26 @@
IMMUTABLE STRICT
LANGUAGE C AS '@MODULE_PATHNAME@', 'pg_uuid_ne';
+CREATE FUNCTION
+ uuid_lt(uuid, uuid) RETURNS BOOL
+ IMMUTABLE STRICT
+ LANGUAGE C AS '@MODULE_PATHNAME@', 'pg_uuid_lt';
+
+CREATE FUNCTION
+ uuid_gt(uuid, uuid) RETURNS BOOL
+ IMMUTABLE STRICT
+ LANGUAGE C AS '@MODULE_PATHNAME@', 'pg_uuid_gt';
+
+CREATE FUNCTION
+ uuid_le(uuid, uuid) RETURNS BOOL
+ IMMUTABLE STRICT
+ LANGUAGE C AS '@MODULE_PATHNAME@', 'pg_uuid_le';
+
+CREATE FUNCTION
+ uuid_ge(uuid, uuid) RETURNS BOOL
+ IMMUTABLE STRICT
+ LANGUAGE C AS '@MODULE_PATHNAME@', 'pg_uuid_ge';
+
CREATE OPERATOR = (
leftarg = uuid,
rightarg = uuid,
@@ -130,6 +175,66 @@
procedure = uuid_ne
);
+CREATE OPERATOR < (
+ leftarg = uuid,
+ rightarg = uuid,
+ commutator = >,
+ negator = >=,
+ procedure = uuid_lt
+);
+
+CREATE OPERATOR > (
+ leftarg = uuid,
+ rightarg = uuid,
+ commutator = <,
+ negator = <=,
+ procedure = uuid_gt
+);
+
+CREATE OPERATOR <= (
+ leftarg = uuid,
+ rightarg = uuid,
+ commutator = >=,
+ negator = >,
+ procedure = uuid_le
+);
+
+CREATE OPERATOR >= (
+ leftarg = uuid,
+ rightarg = uuid,
+ commutator = <=,
+ negator = <,
+ procedure = uuid_ge
+);
+
+--
+-- the UUID support for indexing
+--
+
+CREATE FUNCTION
+ uuid_hash(uuid) RETURNS INTEGER
+ IMMUTABLE STRICT
+ LANGUAGE C AS '@MODULE_PATHNAME@', 'pg_uuid_hash';
+
+CREATE FUNCTION
+ uuid_cmp(uuid, uuid) RETURNS INTEGER
+ IMMUTABLE STRICT
+ LANGUAGE C AS '@MODULE_PATHNAME@', 'pg_uuid_cmp';
+
+CREATE OPERATOR CLASS uuid_ops
+ DEFAULT FOR TYPE uuid USING hash AS
+ OPERATOR 1 =, -- 1: equal
+ FUNCTION 1 uuid_hash(uuid);
+
+CREATE OPERATOR CLASS uuid_ops
+ DEFAULT FOR TYPE uuid USING btree AS
+ OPERATOR 1 <, -- 1: less than
+ OPERATOR 2 <=, -- 2: less than or equal
+ OPERATOR 3 =, -- 3: equal
+ OPERATOR 4 >=, -- 4: greater than or equal
+ OPERATOR 5 >, -- 5: greater than
+ FUNCTION 1 uuid_cmp(uuid, uuid);
+
--
-- epilog
--
|