This repository has been archived by the owner on Apr 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vercomp--1.0.0.sql
93 lines (74 loc) · 4.08 KB
/
vercomp--1.0.0.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
CREATE TYPE version;
CREATE FUNCTION version_in(cstring) RETURNS version AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_out(version) RETURNS cstring AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_to_int(version) RETURNS int AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE TYPE version (INPUT = version_in, OUTPUT = version_out, LIKE = TEXT);
CREATE CAST (text as version) WITHOUT FUNCTION AS IMPLICIT;
CREATE CAST (version as text) WITHOUT FUNCTION AS IMPLICIT;
CREATE CAST (version as int) WITH FUNCTION version_to_int AS IMPLICIT;
CREATE FUNCTION version_cmp(version, version) RETURNS int AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_bump(version, int) RETURNS version AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_eq(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_ne(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_lt(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_le(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_gt(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_ge(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_sat(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_nsat(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_car(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION version_ncar(version, version) RETURNS boolean AS '$libdir/vercomp' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION hash_ver(version) RETURNS int LANGUAGE internal IMMUTABLE AS 'hashtext';
CREATE OPERATOR = (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_eq, COMMUTATOR = '=', NEGATOR = '<>',
RESTRICT = eqsel, JOIN = eqjoinsel, HASHES, MERGES
);
CREATE OPERATOR <> (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_ne, COMMUTATOR = '<>', NEGATOR = '=',
RESTRICT = neqsel, JOIN = neqjoinsel
);
CREATE OPERATOR < (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_lt, COMMUTATOR = > , NEGATOR = >= ,
RESTRICT = scalarltsel, JOIN = scalarltjoinsel
);
CREATE OPERATOR <= (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_le, COMMUTATOR = >= , NEGATOR = > ,
RESTRICT = scalarltsel, JOIN = scalarltjoinsel
);
CREATE OPERATOR > (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_gt, COMMUTATOR = < , NEGATOR = <= ,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
);
CREATE OPERATOR >= (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_ge, COMMUTATOR = <= , NEGATOR = < ,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
);
CREATE OPERATOR ~ (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_sat, COMMUTATOR = ~ , NEGATOR = !~ ,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
);
CREATE OPERATOR !~ (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_nsat, COMMUTATOR = !~ , NEGATOR = ~ ,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
);
CREATE OPERATOR ^ (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_car, COMMUTATOR = ^ , NEGATOR = !^ ,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
);
CREATE OPERATOR !^ (
LEFTARG = version, RIGHTARG = version, PROCEDURE = version_ncar, COMMUTATOR = !^ , NEGATOR = ^ ,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
);
CREATE OPERATOR CLASS btree_ver_ops
DEFAULT FOR TYPE version USING btree
AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 version_cmp(version, version);
CREATE OPERATOR CLASS hash_ver_ops
DEFAULT FOR TYPE version USING hash AS
OPERATOR 1 = ,
FUNCTION 1 hash_ver(version);