-
Notifications
You must be signed in to change notification settings - Fork 29
/
uint.sql
161 lines (125 loc) · 3.82 KB
/
uint.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
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
CREATE TYPE int1;
CREATE FUNCTION int1in(cstring) RETURNS int1
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'int1in';
CREATE FUNCTION int1out(int1) RETURNS cstring
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'int1out';
CREATE TYPE int1 (
INPUT = int1in,
OUTPUT = int1out,
INTERNALLENGTH = 1,
PASSEDBYVALUE,
ALIGNMENT = char
);
CREATE CAST (double precision AS int1) WITH INOUT AS ASSIGNMENT;
CREATE CAST (numeric AS int1) WITH INOUT AS ASSIGNMENT;
CREATE CAST (real AS int1) WITH INOUT AS ASSIGNMENT;
CREATE CAST (int1 AS double precision) WITH INOUT AS IMPLICIT;
CREATE CAST (int1 AS numeric) WITH INOUT AS IMPLICIT;
CREATE CAST (int1 AS real) WITH INOUT AS IMPLICIT;
CREATE TYPE uint1;
CREATE FUNCTION uint1in(cstring) RETURNS uint1
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint1in';
CREATE FUNCTION uint1out(uint1) RETURNS cstring
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint1out';
CREATE TYPE uint1 (
INPUT = uint1in,
OUTPUT = uint1out,
INTERNALLENGTH = 1,
PASSEDBYVALUE,
ALIGNMENT = char
);
CREATE CAST (double precision AS uint1) WITH INOUT AS ASSIGNMENT;
CREATE CAST (numeric AS uint1) WITH INOUT AS ASSIGNMENT;
CREATE CAST (real AS uint1) WITH INOUT AS ASSIGNMENT;
CREATE CAST (uint1 AS double precision) WITH INOUT AS IMPLICIT;
CREATE CAST (uint1 AS numeric) WITH INOUT AS IMPLICIT;
CREATE CAST (uint1 AS real) WITH INOUT AS IMPLICIT;
CREATE TYPE uint2;
CREATE FUNCTION uint2in(cstring) RETURNS uint2
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint2in';
CREATE FUNCTION uint2out(uint2) RETURNS cstring
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint2out';
CREATE TYPE uint2 (
INPUT = uint2in,
OUTPUT = uint2out,
INTERNALLENGTH = 2,
PASSEDBYVALUE,
ALIGNMENT = int2
);
CREATE CAST (double precision AS uint2) WITH INOUT AS ASSIGNMENT;
CREATE CAST (numeric AS uint2) WITH INOUT AS ASSIGNMENT;
CREATE CAST (real AS uint2) WITH INOUT AS ASSIGNMENT;
CREATE CAST (uint2 AS double precision) WITH INOUT AS IMPLICIT;
CREATE CAST (uint2 AS numeric) WITH INOUT AS IMPLICIT;
CREATE CAST (uint2 AS real) WITH INOUT AS IMPLICIT;
CREATE TYPE uint4;
CREATE FUNCTION uint4in(cstring) RETURNS uint4
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint4in';
CREATE FUNCTION uint4out(uint4) RETURNS cstring
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint4out';
CREATE TYPE uint4 (
INPUT = uint4in,
OUTPUT = uint4out,
INTERNALLENGTH = 4,
PASSEDBYVALUE,
ALIGNMENT = int4
);
CREATE CAST (double precision AS uint4) WITH INOUT AS ASSIGNMENT;
CREATE CAST (numeric AS uint4) WITH INOUT AS ASSIGNMENT;
CREATE CAST (real AS uint4) WITH INOUT AS ASSIGNMENT;
CREATE CAST (uint4 AS double precision) WITH INOUT AS IMPLICIT;
CREATE CAST (uint4 AS numeric) WITH INOUT AS IMPLICIT;
CREATE CAST (uint4 AS real) WITH INOUT AS IMPLICIT;
CREATE TYPE uint8;
CREATE FUNCTION uint8in(cstring) RETURNS uint8
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint8in';
CREATE FUNCTION uint8out(uint8) RETURNS cstring
IMMUTABLE
STRICT
LANGUAGE C
AS '$libdir/uint', 'uint8out';
CREATE TYPE uint8 (
INPUT = uint8in,
OUTPUT = uint8out,
INTERNALLENGTH = 8,
PASSEDBYVALUE, -- requires 64-bit
ALIGNMENT = double
);
CREATE CAST (double precision AS uint8) WITH INOUT AS ASSIGNMENT;
CREATE CAST (numeric AS uint8) WITH INOUT AS ASSIGNMENT;
CREATE CAST (real AS uint8) WITH INOUT AS ASSIGNMENT;
CREATE CAST (uint8 AS double precision) WITH INOUT AS IMPLICIT;
CREATE CAST (uint8 AS numeric) WITH INOUT AS IMPLICIT;
CREATE CAST (uint8 AS real) WITH INOUT AS IMPLICIT;
CREATE FUNCTION int1um(int1) RETURNS int1 IMMUTABLE STRICT LANGUAGE C AS '$libdir/uint', 'int1um';
CREATE OPERATOR - (
PROCEDURE = int1um,
RIGHTARG = int1
);