]> git.saurik.com Git - timeuuid.git/blame - timeuuid--1.0.sql
Initial version (seems to work, tested with 9.2).
[timeuuid.git] / timeuuid--1.0.sql
CommitLineData
0f660cfd
JF
1\echo Use "CREATE EXTENSION timeuuid" to load this file. \quit
2
3create type timeuuid;
4
5create or replace function timeuuid_in(cstring) returns timeuuid
6 as 'uuid_in' language internal immutable strict;
7create or replace function timeuuid_out(timeuuid) returns cstring
8 as 'uuid_out' language internal immutable strict;
9
10create or replace function timeuuid_recv(internal) returns timeuuid
11 as 'uuid_recv' language internal immutable strict;
12create or replace function timeuuid_send(timeuuid) returns bytea
13 as 'uuid_send' language internal immutable strict;
14
15create type timeuuid (
16 input = timeuuid_in,
17 output = timeuuid_out,
18 receive = timeuuid_recv,
19 send = timeuuid_send,
20 like = uuid
21);
22
23create or replace function timeuuid_eq(timeuuid, timeuuid) returns boolean
24 as 'uuid_eq' language internal immutable strict;
25create or replace function timeuuid_neq(timeuuid, timeuuid) returns boolean
26 as 'uuid_ne' language internal immutable strict;
27
28create or replace function timeuuid_hash(timeuuid) returns int4
29 as 'uuid_hash' language internal immutable strict;
30
31create function timeuuid_lt(timeuuid, timeuuid) returns boolean
32 as 'MODULE_PATHNAME' language c strict immutable;
33create function timeuuid_gt(timeuuid, timeuuid) returns boolean
34 as 'MODULE_PATHNAME' language c strict immutable;
35create function timeuuid_le(timeuuid, timeuuid) returns boolean
36 as 'MODULE_PATHNAME' language c strict immutable;
37create function timeuuid_ge(timeuuid, timeuuid) returns boolean
38 as 'MODULE_PATHNAME' language c strict immutable;
39
40create function timeuuid_cmp(timeuuid, timeuuid) returns int4
41 as 'MODULE_PATHNAME' language c strict immutable;
42
43create operator = (
44 leftarg = timeuuid,
45 rightarg = timeuuid,
46 commutator = =,
47 negator = <>,
48 procedure = timeuuid_eq,
49 restrict = eqsel,
50 join = eqjoinsel,
51 hashes,
52 merges
53);
54
55create operator <> (
56 leftarg = timeuuid,
57 rightarg = timeuuid,
58 commutator = <>,
59 negator = =,
60 procedure = timeuuid_neq,
61 restrict = neqsel,
62 join = neqjoinsel
63);
64
65create operator < (
66 leftarg = timeuuid,
67 rightarg = timeuuid,
68 commutator = >,
69 negator = >=,
70 procedure = timeuuid_lt,
71 restrict = scalarltsel,
72 join = scalarltjoinsel
73);
74
75create operator > (
76 leftarg = timeuuid,
77 rightarg = timeuuid,
78 commutator = <,
79 negator = <=,
80 procedure = timeuuid_gt,
81 restrict = scalargtsel,
82 join = scalargtjoinsel
83);
84
85create operator <= (
86 leftarg = timeuuid,
87 rightarg = timeuuid,
88 commutator = >=,
89 negator = >,
90 procedure = timeuuid_le,
91 restrict = scalarltsel,
92 join = scalarltjoinsel
93);
94
95create operator >= (
96 leftarg = timeuuid,
97 rightarg = timeuuid,
98 commutator = <=,
99 negator = <,
100 procedure = timeuuid_ge,
101 restrict = scalargtsel,
102 join = scalargtjoinsel
103);
104
105create operator class timeuuid_ops
106default for type timeuuid using btree as
107 operator 1 <,
108 operator 2 <=,
109 operator 3 =,
110 operator 4 >=,
111 operator 5 >,
112 function 1 timeuuid_cmp(timeuuid, timeuuid);
113
114create cast (timeuuid as uuid)
115 without function as assignment;
116create cast (uuid as timeuuid)
117 without function as assignment;
118
119create function timeuuid_to_timestamptz(uuid) returns timestamptz
120 as 'MODULE_PATHNAME' language c strict immutable;
121create function timeuuid_to_timestamptz(timeuuid) returns timestamptz
122 as 'MODULE_PATHNAME' language c strict immutable;
123create function timestamptz_to_timeuuid(timestamptz) returns timeuuid
124 as 'MODULE_PATHNAME' language c strict immutable;
125
126create cast (timeuuid as timestamptz)
127 with function timeuuid_to_timestamptz(timeuuid);
128create cast (timestamptz as timeuuid)
129 with function timestamptz_to_timeuuid(timestamptz);