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
|
--
-- PostgreSQL code for IP addresses.
--
-- $Id: ip.sql,v 1.2 1998/02/14 17:58:04 scrappy Exp $
--
load '/usr/local/pgsql/modules/ip.so';
--
-- Input and output functions and the type itself:
--
create function ipaddr_in(opaque)
returns opaque
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_out(opaque)
returns opaque
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create type ipaddr (
internallength = 6,
externallength = variable,
input = ipaddr_in,
output = ipaddr_out
);
--
-- The various boolean tests:
--
create function ipaddr_lt(ipaddr, ipaddr)
returns bool
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_le(ipaddr, ipaddr)
returns bool
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_eq(ipaddr, ipaddr)
returns bool
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_ge(ipaddr, ipaddr)
returns bool
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_gt(ipaddr, ipaddr)
returns bool
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_ne(ipaddr, ipaddr)
returns bool
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_in_net(ipaddr, ipaddr)
returns bool
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_mask(ipaddr)
returns ipaddr
as '/usr/local/pgsql/modules/ip.so'
language 'c';
create function ipaddr_bcast(ipaddr)
returns ipaddr
as '/usr/local/pgsql/modules/ip.so'
language 'c';
--
-- Now the operators. Note how some of the parameters to some
-- of the 'create operator' commands are commented out. This
-- is because they reference as yet undefined operators, and
-- will be implicitly defined when those are, further down.
--
create operator < (
leftarg = ipaddr,
rightarg = ipaddr,
-- negator = >=,
procedure = ipaddr_lt
);
create operator <= (
leftarg = ipaddr,
rightarg = ipaddr,
-- negator = >,
procedure = ipaddr_le
);
create operator = (
leftarg = ipaddr,
rightarg = ipaddr,
commutator = =,
-- negator = <>,
procedure = ipaddr_eq
);
create operator >= (
leftarg = ipaddr,
rightarg = ipaddr,
negator = <,
procedure = ipaddr_ge
);
create operator > (
leftarg = ipaddr,
rightarg = ipaddr,
negator = <=,
procedure = ipaddr_gt
);
create operator <> (
leftarg = ipaddr,
rightarg = ipaddr,
negator = =,
procedure = ipaddr_ne
);
--
-- eof
--
|