-
Notifications
You must be signed in to change notification settings - Fork 5
/
e164.sql.in
206 lines (167 loc) · 4.08 KB
/
e164.sql.in
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
-- E164 type installation SQL script
-- $Id: e164.sql.in 54 2007-09-10 01:28:30Z glaesema $
SET search_path = public;
BEGIN;
SET LOCAL client_min_messages = notice;
CREATE SCHEMA e164;
SET search_path = e164, public;
CREATE TABLE info (version TEXT PRIMARY KEY,
installed_at TIMESTAMP(0) WITH TIME ZONE NOT NULL UNIQUE
DEFAULT CURRENT_TIMESTAMP,
scm_revision INTEGER NOT NULL UNIQUE);
INSERT INTO info (version, scm_revision)
VALUES ('0.1', CAST(SUBSTRING('$Revision: 54 $' FROM $re$\d+$re$) AS INTEGER));
CREATE OR REPLACE FUNCTION e164_in(cstring)
RETURNS e164
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_out(e164)
RETURNS cstring
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_recv(internal)
RETURNS e164
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_send(e164)
RETURNS bytea
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE TYPE e164
(
INTERNALLENGTH = 8
, INPUT = e164_in
, OUTPUT = e164_out
, RECEIVE = e164_recv
, SEND = e164_send
, ALIGNMENT = double
);
COMMENT ON TYPE e164 IS
'';
COMMIT;
CREATE OR REPLACE FUNCTION e164_hash(e164)
RETURNS integer
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME', 'e164_hash';
BEGIN;
SET LOCAL client_min_messages = notice;
CREATE OR REPLACE FUNCTION e164_cmp(e164, e164)
RETURNS INTEGER
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_lt(e164, e164)
RETURNS BOOLEAN
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_le(e164, e164)
RETURNS BOOLEAN
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_ge(e164, e164)
RETURNS BOOLEAN
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_gt(e164, e164)
RETURNS BOOLEAN
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_eq(e164, e164)
RETURNS BOOLEAN
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION e164_ne(e164, e164)
RETURNS BOOLEAN
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
COMMIT;
CREATE OPERATOR <
(
LEFTARG = e164
, RIGHTARG = e164
, PROCEDURE = e164_lt
, COMMUTATOR = '>'
, NEGATOR = '>='
, RESTRICT = scalarltsel
, JOIN = scalarltjoinsel
);
CREATE OPERATOR <=
(
LEFTARG = e164
, RIGHTARG = e164
, PROCEDURE = e164_le
, COMMUTATOR = '>='
, NEGATOR = '>'
, RESTRICT = scalarltsel
, JOIN = scalarltjoinsel
);
CREATE OPERATOR >=
(
LEFTARG = e164
, RIGHTARG = e164
, PROCEDURE = e164_ge
, COMMUTATOR = '<='
, NEGATOR = '<'
, RESTRICT = scalargtsel
, JOIN = scalargtjoinsel
);
CREATE OPERATOR >
(
LEFTARG = e164
, RIGHTARG = e164
, PROCEDURE = e164_le
, COMMUTATOR = '<'
, NEGATOR = '<='
, RESTRICT = scalargtsel
, JOIN = scalargtjoinsel
);
CREATE OPERATOR =
(
LEFTARG = e164
, RIGHTARG = e164
, PROCEDURE = e164_eq
, COMMUTATOR = '='
, NEGATOR = '<>'
, RESTRICT = eqsel
, JOIN = eqjoinsel
, SORT1 = '<'
, SORT2 = '<'
, HASHES
);
CREATE OPERATOR <>
(
LEFTARG = e164
, RIGHTARG = e164
, PROCEDURE = e164_ne
, COMMUTATOR = '<>'
, NEGATOR = '='
, RESTRICT = neqsel
, JOIN = neqjoinsel
);
-- Casts
CREATE FUNCTION text(e164)
RETURNS text
AS 'MODULE_PATHNAME', 'e164_cast_to_text'
LANGUAGE 'C' IMMUTABLE STRICT;
CREATE CAST (e164 AS text) WITH FUNCTION text(e164);
-- Create the operator classes for indexing
CREATE OPERATOR CLASS btree_e164_ops
DEFAULT FOR TYPE e164 USING btree
AS OPERATOR 1 <
, OPERATOR 2 <=
, OPERATOR 3 =
, OPERATOR 4 >=
, OPERATOR 5 >
, FUNCTION 1 e164_cmp(e164, e164);
CREATE OPERATOR CLASS hash_e164_ops
DEFAULT FOR TYPE e164 USING hash
AS OPERATOR 1 =
, FUNCTION 1 e164_hash(e164);
CREATE OR REPLACE FUNCTION country_code(e164)
RETURNS TEXT
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
CREATE OR REPLACE FUNCTION is_consistent(e164)
RETURNS BOOLEAN
IMMUTABLE STRICT
LANGUAGE 'C' AS 'MODULE_PATHNAME';
-- end