globegit-postgresql-plruby 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +121 -0
- data/README.markdown +155 -0
- data/Rakefile +48 -0
- data/docs/plruby.rb +1931 -0
- data/ex_trans.sql +33 -0
- data/extconf.rb +267 -0
- data/plruby.html +1454 -0
- data/plruby.rd +1571 -0
- data/postgresql-plruby.gemspec +56 -0
- data/src/conversions.h +5 -0
- data/src/conversions/basic/conversions.h +25 -0
- data/src/conversions/basic/extconf.rb +8 -0
- data/src/conversions/basic/plruby_basic.c +357 -0
- data/src/conversions/bitstring/bitstring.sql +75 -0
- data/src/conversions/bitstring/conversions.h +15 -0
- data/src/conversions/bitstring/extconf.rb +8 -0
- data/src/conversions/bitstring/plruby_bitstring.c +579 -0
- data/src/conversions/convcommon.h +129 -0
- data/src/conversions/datetime/conversions.h +13 -0
- data/src/conversions/datetime/extconf.rb +8 -0
- data/src/conversions/datetime/plruby_datetime.c +269 -0
- data/src/conversions/geometry/conversions.h +37 -0
- data/src/conversions/geometry/extconf.rb +8 -0
- data/src/conversions/geometry/geometry.sql +196 -0
- data/src/conversions/geometry/plruby_geometry.c +2494 -0
- data/src/conversions/network/conversions.h +21 -0
- data/src/conversions/network/extconf.rb +8 -0
- data/src/conversions/network/network.sql +63 -0
- data/src/conversions/network/plruby_network.c +537 -0
- data/src/package.h +20 -0
- data/src/plpl.c +1708 -0
- data/src/plplan.c +893 -0
- data/src/plruby.c +1676 -0
- data/src/plruby.h +324 -0
- data/src/pltrans.c +388 -0
- data/test/conv_bitstring/b.rb +45 -0
- data/test/conv_bitstring/runtest +26 -0
- data/test/conv_bitstring/test.expected.73 +148 -0
- data/test/conv_bitstring/test.expected.74 +148 -0
- data/test/conv_bitstring/test.expected.80 +148 -0
- data/test/conv_bitstring/test.expected.81 +148 -0
- data/test/conv_bitstring/test.expected.82 +148 -0
- data/test/conv_bitstring/test.expected.83 +148 -0
- data/test/conv_bitstring/test.expected.84 +148 -0
- data/test/conv_bitstring/test.out +148 -0
- data/test/conv_bitstring/test_mklang.sql +8 -0
- data/test/conv_bitstring/test_queries.sql +63 -0
- data/test/conv_bitstring/test_queries.sql.in +63 -0
- data/test/conv_geometry/b.rb +45 -0
- data/test/conv_geometry/runtest +26 -0
- data/test/conv_geometry/test.expected.73 +265 -0
- data/test/conv_geometry/test.expected.74 +265 -0
- data/test/conv_geometry/test.expected.80 +265 -0
- data/test/conv_geometry/test.expected.81 +265 -0
- data/test/conv_geometry/test.expected.82 +265 -0
- data/test/conv_geometry/test.expected.83 +265 -0
- data/test/conv_geometry/test.expected.84 +265 -0
- data/test/conv_geometry/test.out +265 -0
- data/test/conv_geometry/test_mklang.sql +8 -0
- data/test/conv_geometry/test_queries.sql +194 -0
- data/test/conv_geometry/test_queries.sql.in +194 -0
- data/test/conv_network/b.rb +45 -0
- data/test/conv_network/runtest +26 -0
- data/test/conv_network/test.expected.73 +213 -0
- data/test/conv_network/test.expected.74 +237 -0
- data/test/conv_network/test.expected.80 +237 -0
- data/test/conv_network/test.expected.81 +237 -0
- data/test/conv_network/test.expected.82 +237 -0
- data/test/conv_network/test.expected.83 +237 -0
- data/test/conv_network/test.expected.84 +237 -0
- data/test/conv_network/test.out +237 -0
- data/test/conv_network/test_mklang.sql +8 -0
- data/test/conv_network/test_queries.sql +60 -0
- data/test/conv_network/test_queries.sql.in +60 -0
- data/test/plp/b.rb +34 -0
- data/test/plp/runtest +29 -0
- data/test/plp/test.expected.73 +472 -0
- data/test/plp/test.expected.74 +472 -0
- data/test/plp/test.expected.75 +472 -0
- data/test/plp/test.expected.80 +472 -0
- data/test/plp/test.expected.81 +472 -0
- data/test/plp/test.expected.82 +472 -0
- data/test/plp/test.expected.83 +472 -0
- data/test/plp/test.expected.84 +472 -0
- data/test/plp/test.out +472 -0
- data/test/plp/test_mklang.sql +8 -0
- data/test/plp/test_queries.sql +273 -0
- data/test/plp/test_setup.sql +931 -0
- data/test/plp/test_setup.sql.in +931 -0
- data/test/plt/b.rb +34 -0
- data/test/plt/runtest +29 -0
- data/test/plt/test.expected.73 +178 -0
- data/test/plt/test.expected.74 +178 -0
- data/test/plt/test.expected.75 +178 -0
- data/test/plt/test.expected.80 +178 -0
- data/test/plt/test.expected.81 +178 -0
- data/test/plt/test.expected.82 +178 -0
- data/test/plt/test.expected.83 +164 -0
- data/test/plt/test.expected.84 +168 -0
- data/test/plt/test.out +168 -0
- data/test/plt/test_mklang.sql +8 -0
- data/test/plt/test_queries.sql +72 -0
- data/test/plt/test_setup.sql +252 -0
- data/test/plt/test_setup.sql.in +252 -0
- data/test/range/b.rb +45 -0
- data/test/range/runtest +26 -0
- data/test/range/test.expected.73 +396 -0
- data/test/range/test.expected.73.in +396 -0
- data/test/range/test.expected.74 +396 -0
- data/test/range/test.expected.74.in +396 -0
- data/test/range/test.expected.75 +396 -0
- data/test/range/test.expected.75.in +396 -0
- data/test/range/test.expected.80 +396 -0
- data/test/range/test.expected.81 +397 -0
- data/test/range/test.expected.82 +397 -0
- data/test/range/test.expected.83 +397 -0
- data/test/range/test.expected.84 +399 -0
- data/test/range/test.out +399 -0
- data/test/range/test_mklang.sql +8 -0
- data/test/range/test_queries.sql +249 -0
- data/test/range/test_queries.sql.in +249 -0
- metadata +207 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
create table pl_inet (
|
2
|
+
host text, abbrev text, masklen int,
|
3
|
+
network inet, netmask inet, first inet, last inet
|
4
|
+
);
|
5
|
+
create or replace function inet_val(inet) returns pl_inet as '
|
6
|
+
a = args[0]
|
7
|
+
[a.host, a.abbrev, a.masklen, a.network, a.netmask,
|
8
|
+
a.first, a.last]
|
9
|
+
' language 'plruby';
|
10
|
+
select * from inet_val('192.168.1'::cidr);
|
11
|
+
host | abbrev | masklen | network | netmask | first | last
|
12
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
13
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
14
|
+
(1 row)
|
15
|
+
|
16
|
+
select * from inet_val('192.168.1.226/24'::inet);
|
17
|
+
host | abbrev | masklen | network | netmask | first | last
|
18
|
+
---------------+------------------+---------+----------------+---------------+----------------+---------------
|
19
|
+
192.168.1.226 | 192.168.1.226/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
20
|
+
(1 row)
|
21
|
+
|
22
|
+
select * from inet_val('192.168.1.0/24'::cidr);
|
23
|
+
host | abbrev | masklen | network | netmask | first | last
|
24
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
25
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
26
|
+
(1 row)
|
27
|
+
|
28
|
+
select * from inet_val('192.168.1.226'::inet);
|
29
|
+
host | abbrev | masklen | network | netmask | first | last
|
30
|
+
---------------+---------------+---------+------------------+-----------------+------------------+---------------
|
31
|
+
192.168.1.226 | 192.168.1.226 | 32 | 192.168.1.226/32 | 255.255.255.255 | 192.168.1.226/32 | 192.168.1.226
|
32
|
+
(1 row)
|
33
|
+
|
34
|
+
select * from inet_val('192.168.1'::cidr);
|
35
|
+
host | abbrev | masklen | network | netmask | first | last
|
36
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
37
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
38
|
+
(1 row)
|
39
|
+
|
40
|
+
select * from inet_val('192.168.1.0/24'::inet);
|
41
|
+
host | abbrev | masklen | network | netmask | first | last
|
42
|
+
-------------+----------------+---------+----------------+---------------+----------------+---------------
|
43
|
+
192.168.1.0 | 192.168.1.0/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
44
|
+
(1 row)
|
45
|
+
|
46
|
+
select * from inet_val('192.168.1'::cidr);
|
47
|
+
host | abbrev | masklen | network | netmask | first | last
|
48
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
49
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
50
|
+
(1 row)
|
51
|
+
|
52
|
+
select * from inet_val('192.168.1.0/25'::inet);
|
53
|
+
host | abbrev | masklen | network | netmask | first | last
|
54
|
+
-------------+----------------+---------+----------------+-----------------+----------------+---------------
|
55
|
+
192.168.1.0 | 192.168.1.0/25 | 25 | 192.168.1.0/25 | 255.255.255.128 | 192.168.1.0/25 | 192.168.1.127
|
56
|
+
(1 row)
|
57
|
+
|
58
|
+
select * from inet_val('192.168.1'::cidr);
|
59
|
+
host | abbrev | masklen | network | netmask | first | last
|
60
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
61
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
62
|
+
(1 row)
|
63
|
+
|
64
|
+
select * from inet_val('192.168.1.255/24'::inet);
|
65
|
+
host | abbrev | masklen | network | netmask | first | last
|
66
|
+
---------------+------------------+---------+----------------+---------------+----------------+---------------
|
67
|
+
192.168.1.255 | 192.168.1.255/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
68
|
+
(1 row)
|
69
|
+
|
70
|
+
select * from inet_val('192.168.1'::cidr);
|
71
|
+
host | abbrev | masklen | network | netmask | first | last
|
72
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
73
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
74
|
+
(1 row)
|
75
|
+
|
76
|
+
select * from inet_val('192.168.1.255/25'::inet);
|
77
|
+
host | abbrev | masklen | network | netmask | first | last
|
78
|
+
---------------+------------------+---------+------------------+-----------------+------------------+---------------
|
79
|
+
192.168.1.255 | 192.168.1.255/25 | 25 | 192.168.1.128/25 | 255.255.255.128 | 192.168.1.128/25 | 192.168.1.255
|
80
|
+
(1 row)
|
81
|
+
|
82
|
+
select * from inet_val('10'::cidr);
|
83
|
+
host | abbrev | masklen | network | netmask | first | last
|
84
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
85
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
86
|
+
(1 row)
|
87
|
+
|
88
|
+
select * from inet_val('10.1.2.3/8'::inet);
|
89
|
+
host | abbrev | masklen | network | netmask | first | last
|
90
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
91
|
+
10.1.2.3 | 10.1.2.3/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
92
|
+
(1 row)
|
93
|
+
|
94
|
+
select * from inet_val('10.0.0.0'::cidr);
|
95
|
+
host | abbrev | masklen | network | netmask | first | last
|
96
|
+
----------+-------------+---------+-------------+-----------------+-------------+----------
|
97
|
+
10.0.0.0 | 10.0.0.0/32 | 32 | 10.0.0.0/32 | 255.255.255.255 | 10.0.0.0/32 | 10.0.0.0
|
98
|
+
(1 row)
|
99
|
+
|
100
|
+
select * from inet_val('10.1.2.3/8'::inet);
|
101
|
+
host | abbrev | masklen | network | netmask | first | last
|
102
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
103
|
+
10.1.2.3 | 10.1.2.3/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
104
|
+
(1 row)
|
105
|
+
|
106
|
+
select * from inet_val('10.1.2.3'::cidr);
|
107
|
+
host | abbrev | masklen | network | netmask | first | last
|
108
|
+
----------+-------------+---------+-------------+-----------------+-------------+----------
|
109
|
+
10.1.2.3 | 10.1.2.3/32 | 32 | 10.1.2.3/32 | 255.255.255.255 | 10.1.2.3/32 | 10.1.2.3
|
110
|
+
(1 row)
|
111
|
+
|
112
|
+
select * from inet_val('10.1.2.3/32'::inet);
|
113
|
+
host | abbrev | masklen | network | netmask | first | last
|
114
|
+
----------+----------+---------+-------------+-----------------+-------------+----------
|
115
|
+
10.1.2.3 | 10.1.2.3 | 32 | 10.1.2.3/32 | 255.255.255.255 | 10.1.2.3/32 | 10.1.2.3
|
116
|
+
(1 row)
|
117
|
+
|
118
|
+
select * from inet_val('10.1.2'::cidr);
|
119
|
+
host | abbrev | masklen | network | netmask | first | last
|
120
|
+
----------+-----------+---------+-------------+---------------+-------------+------------
|
121
|
+
10.1.2.0 | 10.1.2/24 | 24 | 10.1.2.0/24 | 255.255.255.0 | 10.1.2.0/24 | 10.1.2.255
|
122
|
+
(1 row)
|
123
|
+
|
124
|
+
select * from inet_val('10.1.2.3/24'::inet);
|
125
|
+
host | abbrev | masklen | network | netmask | first | last
|
126
|
+
----------+-------------+---------+-------------+---------------+-------------+------------
|
127
|
+
10.1.2.3 | 10.1.2.3/24 | 24 | 10.1.2.0/24 | 255.255.255.0 | 10.1.2.0/24 | 10.1.2.255
|
128
|
+
(1 row)
|
129
|
+
|
130
|
+
select * from inet_val('10.1'::cidr);
|
131
|
+
host | abbrev | masklen | network | netmask | first | last
|
132
|
+
----------+---------+---------+-------------+-------------+-------------+--------------
|
133
|
+
10.1.0.0 | 10.1/16 | 16 | 10.1.0.0/16 | 255.255.0.0 | 10.1.0.0/16 | 10.1.255.255
|
134
|
+
(1 row)
|
135
|
+
|
136
|
+
select * from inet_val('10.1.2.3/16'::inet);
|
137
|
+
host | abbrev | masklen | network | netmask | first | last
|
138
|
+
----------+-------------+---------+-------------+-------------+-------------+--------------
|
139
|
+
10.1.2.3 | 10.1.2.3/16 | 16 | 10.1.0.0/16 | 255.255.0.0 | 10.1.0.0/16 | 10.1.255.255
|
140
|
+
(1 row)
|
141
|
+
|
142
|
+
select * from inet_val('10'::cidr);
|
143
|
+
host | abbrev | masklen | network | netmask | first | last
|
144
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
145
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
146
|
+
(1 row)
|
147
|
+
|
148
|
+
select * from inet_val('10.1.2.3/8'::inet);
|
149
|
+
host | abbrev | masklen | network | netmask | first | last
|
150
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
151
|
+
10.1.2.3 | 10.1.2.3/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
152
|
+
(1 row)
|
153
|
+
|
154
|
+
select * from inet_val('10'::cidr);
|
155
|
+
host | abbrev | masklen | network | netmask | first | last
|
156
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
157
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
158
|
+
(1 row)
|
159
|
+
|
160
|
+
select * from inet_val('11.1.2.3/8'::inet);
|
161
|
+
host | abbrev | masklen | network | netmask | first | last
|
162
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
163
|
+
11.1.2.3 | 11.1.2.3/8 | 8 | 11.0.0.0/8 | 255.0.0.0 | 11.0.0.0/8 | 11.255.255.255
|
164
|
+
(1 row)
|
165
|
+
|
166
|
+
select * from inet_val('10'::cidr);
|
167
|
+
host | abbrev | masklen | network | netmask | first | last
|
168
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
169
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
170
|
+
(1 row)
|
171
|
+
|
172
|
+
select * from inet_val('9.1.2.3/8'::inet);
|
173
|
+
host | abbrev | masklen | network | netmask | first | last
|
174
|
+
---------+-----------+---------+-----------+-----------+-----------+---------------
|
175
|
+
9.1.2.3 | 9.1.2.3/8 | 8 | 9.0.0.0/8 | 255.0.0.0 | 9.0.0.0/8 | 9.255.255.255
|
176
|
+
(1 row)
|
177
|
+
|
178
|
+
select * from inet_val('10:23::f1'::cidr);
|
179
|
+
host | abbrev | masklen | network | netmask | first | last
|
180
|
+
-----------+---------------+---------+---------------+-----------------------------------------+---------------+-----------
|
181
|
+
10:23::f1 | 10:23::f1/128 | 128 | 10:23::f1/128 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | 10:23::f1/128 | 10:23::f1
|
182
|
+
(1 row)
|
183
|
+
|
184
|
+
select * from inet_val('10:23::f1/64'::inet);
|
185
|
+
host | abbrev | masklen | network | netmask | first | last
|
186
|
+
-----------+--------------+---------+------------+-----------------------+------------+----------------------------
|
187
|
+
10:23::f1 | 10:23::f1/64 | 64 | 10:23::/64 | ffff:ffff:ffff:ffff:: | 10:23::/64 | 10:23::ffff:ffff:ffff:ffff
|
188
|
+
(1 row)
|
189
|
+
|
190
|
+
select * from inet_val('10:23::8000/113'::cidr);
|
191
|
+
host | abbrev | masklen | network | netmask | first | last
|
192
|
+
-------------+-----------------+---------+-----------------+-----------------------------------------+-----------------+-------------
|
193
|
+
10:23::8000 | 10:23::8000/113 | 113 | 10:23::8000/113 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000 | 10:23::8000/113 | 10:23::ffff
|
194
|
+
(1 row)
|
195
|
+
|
196
|
+
select * from inet_val('10:23::ffff'::inet);
|
197
|
+
host | abbrev | masklen | network | netmask | first | last
|
198
|
+
-------------+-------------+---------+-----------------+-----------------------------------------+-----------------+-------------
|
199
|
+
10:23::ffff | 10:23::ffff | 128 | 10:23::ffff/128 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | 10:23::ffff/128 | 10:23::ffff
|
200
|
+
(1 row)
|
201
|
+
|
202
|
+
select * from inet_val('::ffff:1.2.3.4'::cidr);
|
203
|
+
host | abbrev | masklen | network | netmask | first | last
|
204
|
+
----------------+--------------------+---------+--------------------+-----------------------------------------+--------------------+----------------
|
205
|
+
::ffff:1.2.3.4 | ::ffff:1.2.3.4/128 | 128 | ::ffff:1.2.3.4/128 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | ::ffff:1.2.3.4/128 | ::ffff:1.2.3.4
|
206
|
+
(1 row)
|
207
|
+
|
208
|
+
select * from inet_val('::4.3.2.1/24'::inet);
|
209
|
+
host | abbrev | masklen | network | netmask | first | last
|
210
|
+
-----------+--------------+---------+---------+-------------+-------+------------------------------------
|
211
|
+
::4.3.2.1 | ::4.3.2.1/24 | 24 | ::/24 | ffff:ff00:: | ::/24 | 0:ff:ffff:ffff:ffff:ffff:ffff:ffff
|
212
|
+
(1 row)
|
213
|
+
|
214
|
+
create or replace function mac_cmp(macaddr, macaddr) returns int as '
|
215
|
+
args[0] <=> args[1]
|
216
|
+
' language 'plruby';
|
217
|
+
select mac_cmp('00:07:E9:85:3E:C5'::macaddr, '00:E0:29:3E:E7:25'::macaddr);
|
218
|
+
mac_cmp
|
219
|
+
---------
|
220
|
+
-1
|
221
|
+
(1 row)
|
222
|
+
|
223
|
+
create or replace function mac_trunc(macaddr) returns macaddr as '
|
224
|
+
args[0].truncate
|
225
|
+
' language 'plruby';
|
226
|
+
select mac_trunc('00:07:E9:85:3E:C5'::macaddr);
|
227
|
+
mac_trunc
|
228
|
+
-------------------
|
229
|
+
00:07:e9:00:00:00
|
230
|
+
(1 row)
|
231
|
+
|
232
|
+
select mac_trunc('00:E0:29:3E:E7:25'::macaddr);
|
233
|
+
mac_trunc
|
234
|
+
-------------------
|
235
|
+
00:e0:29:00:00:00
|
236
|
+
(1 row)
|
237
|
+
|
@@ -0,0 +1,237 @@
|
|
1
|
+
create table pl_inet (
|
2
|
+
host text, abbrev text, masklen int,
|
3
|
+
network inet, netmask inet, first inet, last inet
|
4
|
+
);
|
5
|
+
create or replace function inet_val(inet) returns pl_inet as '
|
6
|
+
a = args[0]
|
7
|
+
[a.host, a.abbrev, a.masklen, a.network, a.netmask,
|
8
|
+
a.first, a.last]
|
9
|
+
' language 'plruby';
|
10
|
+
select * from inet_val('192.168.1'::cidr);
|
11
|
+
host | abbrev | masklen | network | netmask | first | last
|
12
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
13
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
14
|
+
(1 row)
|
15
|
+
|
16
|
+
select * from inet_val('192.168.1.226/24'::inet);
|
17
|
+
host | abbrev | masklen | network | netmask | first | last
|
18
|
+
---------------+------------------+---------+----------------+---------------+----------------+---------------
|
19
|
+
192.168.1.226 | 192.168.1.226/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
20
|
+
(1 row)
|
21
|
+
|
22
|
+
select * from inet_val('192.168.1.0/24'::cidr);
|
23
|
+
host | abbrev | masklen | network | netmask | first | last
|
24
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
25
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
26
|
+
(1 row)
|
27
|
+
|
28
|
+
select * from inet_val('192.168.1.226'::inet);
|
29
|
+
host | abbrev | masklen | network | netmask | first | last
|
30
|
+
---------------+---------------+---------+------------------+-----------------+------------------+---------------
|
31
|
+
192.168.1.226 | 192.168.1.226 | 32 | 192.168.1.226/32 | 255.255.255.255 | 192.168.1.226/32 | 192.168.1.226
|
32
|
+
(1 row)
|
33
|
+
|
34
|
+
select * from inet_val('192.168.1'::cidr);
|
35
|
+
host | abbrev | masklen | network | netmask | first | last
|
36
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
37
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
38
|
+
(1 row)
|
39
|
+
|
40
|
+
select * from inet_val('192.168.1.0/24'::inet);
|
41
|
+
host | abbrev | masklen | network | netmask | first | last
|
42
|
+
-------------+----------------+---------+----------------+---------------+----------------+---------------
|
43
|
+
192.168.1.0 | 192.168.1.0/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
44
|
+
(1 row)
|
45
|
+
|
46
|
+
select * from inet_val('192.168.1'::cidr);
|
47
|
+
host | abbrev | masklen | network | netmask | first | last
|
48
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
49
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
50
|
+
(1 row)
|
51
|
+
|
52
|
+
select * from inet_val('192.168.1.0/25'::inet);
|
53
|
+
host | abbrev | masklen | network | netmask | first | last
|
54
|
+
-------------+----------------+---------+----------------+-----------------+----------------+---------------
|
55
|
+
192.168.1.0 | 192.168.1.0/25 | 25 | 192.168.1.0/25 | 255.255.255.128 | 192.168.1.0/25 | 192.168.1.127
|
56
|
+
(1 row)
|
57
|
+
|
58
|
+
select * from inet_val('192.168.1'::cidr);
|
59
|
+
host | abbrev | masklen | network | netmask | first | last
|
60
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
61
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
62
|
+
(1 row)
|
63
|
+
|
64
|
+
select * from inet_val('192.168.1.255/24'::inet);
|
65
|
+
host | abbrev | masklen | network | netmask | first | last
|
66
|
+
---------------+------------------+---------+----------------+---------------+----------------+---------------
|
67
|
+
192.168.1.255 | 192.168.1.255/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
68
|
+
(1 row)
|
69
|
+
|
70
|
+
select * from inet_val('192.168.1'::cidr);
|
71
|
+
host | abbrev | masklen | network | netmask | first | last
|
72
|
+
-------------+--------------+---------+----------------+---------------+----------------+---------------
|
73
|
+
192.168.1.0 | 192.168.1/24 | 24 | 192.168.1.0/24 | 255.255.255.0 | 192.168.1.0/24 | 192.168.1.255
|
74
|
+
(1 row)
|
75
|
+
|
76
|
+
select * from inet_val('192.168.1.255/25'::inet);
|
77
|
+
host | abbrev | masklen | network | netmask | first | last
|
78
|
+
---------------+------------------+---------+------------------+-----------------+------------------+---------------
|
79
|
+
192.168.1.255 | 192.168.1.255/25 | 25 | 192.168.1.128/25 | 255.255.255.128 | 192.168.1.128/25 | 192.168.1.255
|
80
|
+
(1 row)
|
81
|
+
|
82
|
+
select * from inet_val('10'::cidr);
|
83
|
+
host | abbrev | masklen | network | netmask | first | last
|
84
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
85
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
86
|
+
(1 row)
|
87
|
+
|
88
|
+
select * from inet_val('10.1.2.3/8'::inet);
|
89
|
+
host | abbrev | masklen | network | netmask | first | last
|
90
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
91
|
+
10.1.2.3 | 10.1.2.3/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
92
|
+
(1 row)
|
93
|
+
|
94
|
+
select * from inet_val('10.0.0.0'::cidr);
|
95
|
+
host | abbrev | masklen | network | netmask | first | last
|
96
|
+
----------+-------------+---------+-------------+-----------------+-------------+----------
|
97
|
+
10.0.0.0 | 10.0.0.0/32 | 32 | 10.0.0.0/32 | 255.255.255.255 | 10.0.0.0/32 | 10.0.0.0
|
98
|
+
(1 row)
|
99
|
+
|
100
|
+
select * from inet_val('10.1.2.3/8'::inet);
|
101
|
+
host | abbrev | masklen | network | netmask | first | last
|
102
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
103
|
+
10.1.2.3 | 10.1.2.3/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
104
|
+
(1 row)
|
105
|
+
|
106
|
+
select * from inet_val('10.1.2.3'::cidr);
|
107
|
+
host | abbrev | masklen | network | netmask | first | last
|
108
|
+
----------+-------------+---------+-------------+-----------------+-------------+----------
|
109
|
+
10.1.2.3 | 10.1.2.3/32 | 32 | 10.1.2.3/32 | 255.255.255.255 | 10.1.2.3/32 | 10.1.2.3
|
110
|
+
(1 row)
|
111
|
+
|
112
|
+
select * from inet_val('10.1.2.3/32'::inet);
|
113
|
+
host | abbrev | masklen | network | netmask | first | last
|
114
|
+
----------+----------+---------+-------------+-----------------+-------------+----------
|
115
|
+
10.1.2.3 | 10.1.2.3 | 32 | 10.1.2.3/32 | 255.255.255.255 | 10.1.2.3/32 | 10.1.2.3
|
116
|
+
(1 row)
|
117
|
+
|
118
|
+
select * from inet_val('10.1.2'::cidr);
|
119
|
+
host | abbrev | masklen | network | netmask | first | last
|
120
|
+
----------+-----------+---------+-------------+---------------+-------------+------------
|
121
|
+
10.1.2.0 | 10.1.2/24 | 24 | 10.1.2.0/24 | 255.255.255.0 | 10.1.2.0/24 | 10.1.2.255
|
122
|
+
(1 row)
|
123
|
+
|
124
|
+
select * from inet_val('10.1.2.3/24'::inet);
|
125
|
+
host | abbrev | masklen | network | netmask | first | last
|
126
|
+
----------+-------------+---------+-------------+---------------+-------------+------------
|
127
|
+
10.1.2.3 | 10.1.2.3/24 | 24 | 10.1.2.0/24 | 255.255.255.0 | 10.1.2.0/24 | 10.1.2.255
|
128
|
+
(1 row)
|
129
|
+
|
130
|
+
select * from inet_val('10.1'::cidr);
|
131
|
+
host | abbrev | masklen | network | netmask | first | last
|
132
|
+
----------+---------+---------+-------------+-------------+-------------+--------------
|
133
|
+
10.1.0.0 | 10.1/16 | 16 | 10.1.0.0/16 | 255.255.0.0 | 10.1.0.0/16 | 10.1.255.255
|
134
|
+
(1 row)
|
135
|
+
|
136
|
+
select * from inet_val('10.1.2.3/16'::inet);
|
137
|
+
host | abbrev | masklen | network | netmask | first | last
|
138
|
+
----------+-------------+---------+-------------+-------------+-------------+--------------
|
139
|
+
10.1.2.3 | 10.1.2.3/16 | 16 | 10.1.0.0/16 | 255.255.0.0 | 10.1.0.0/16 | 10.1.255.255
|
140
|
+
(1 row)
|
141
|
+
|
142
|
+
select * from inet_val('10'::cidr);
|
143
|
+
host | abbrev | masklen | network | netmask | first | last
|
144
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
145
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
146
|
+
(1 row)
|
147
|
+
|
148
|
+
select * from inet_val('10.1.2.3/8'::inet);
|
149
|
+
host | abbrev | masklen | network | netmask | first | last
|
150
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
151
|
+
10.1.2.3 | 10.1.2.3/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
152
|
+
(1 row)
|
153
|
+
|
154
|
+
select * from inet_val('10'::cidr);
|
155
|
+
host | abbrev | masklen | network | netmask | first | last
|
156
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
157
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
158
|
+
(1 row)
|
159
|
+
|
160
|
+
select * from inet_val('11.1.2.3/8'::inet);
|
161
|
+
host | abbrev | masklen | network | netmask | first | last
|
162
|
+
----------+------------+---------+------------+-----------+------------+----------------
|
163
|
+
11.1.2.3 | 11.1.2.3/8 | 8 | 11.0.0.0/8 | 255.0.0.0 | 11.0.0.0/8 | 11.255.255.255
|
164
|
+
(1 row)
|
165
|
+
|
166
|
+
select * from inet_val('10'::cidr);
|
167
|
+
host | abbrev | masklen | network | netmask | first | last
|
168
|
+
----------+--------+---------+------------+-----------+------------+----------------
|
169
|
+
10.0.0.0 | 10/8 | 8 | 10.0.0.0/8 | 255.0.0.0 | 10.0.0.0/8 | 10.255.255.255
|
170
|
+
(1 row)
|
171
|
+
|
172
|
+
select * from inet_val('9.1.2.3/8'::inet);
|
173
|
+
host | abbrev | masklen | network | netmask | first | last
|
174
|
+
---------+-----------+---------+-----------+-----------+-----------+---------------
|
175
|
+
9.1.2.3 | 9.1.2.3/8 | 8 | 9.0.0.0/8 | 255.0.0.0 | 9.0.0.0/8 | 9.255.255.255
|
176
|
+
(1 row)
|
177
|
+
|
178
|
+
select * from inet_val('10:23::f1'::cidr);
|
179
|
+
host | abbrev | masklen | network | netmask | first | last
|
180
|
+
-----------+---------------+---------+---------------+-----------------------------------------+---------------+-----------
|
181
|
+
10:23::f1 | 10:23::f1/128 | 128 | 10:23::f1/128 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | 10:23::f1/128 | 10:23::f1
|
182
|
+
(1 row)
|
183
|
+
|
184
|
+
select * from inet_val('10:23::f1/64'::inet);
|
185
|
+
host | abbrev | masklen | network | netmask | first | last
|
186
|
+
-----------+--------------+---------+------------+-----------------------+------------+----------------------------
|
187
|
+
10:23::f1 | 10:23::f1/64 | 64 | 10:23::/64 | ffff:ffff:ffff:ffff:: | 10:23::/64 | 10:23::ffff:ffff:ffff:ffff
|
188
|
+
(1 row)
|
189
|
+
|
190
|
+
select * from inet_val('10:23::8000/113'::cidr);
|
191
|
+
host | abbrev | masklen | network | netmask | first | last
|
192
|
+
-------------+-----------------+---------+-----------------+-----------------------------------------+-----------------+-------------
|
193
|
+
10:23::8000 | 10:23::8000/113 | 113 | 10:23::8000/113 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000 | 10:23::8000/113 | 10:23::ffff
|
194
|
+
(1 row)
|
195
|
+
|
196
|
+
select * from inet_val('10:23::ffff'::inet);
|
197
|
+
host | abbrev | masklen | network | netmask | first | last
|
198
|
+
-------------+-------------+---------+-----------------+-----------------------------------------+-----------------+-------------
|
199
|
+
10:23::ffff | 10:23::ffff | 128 | 10:23::ffff/128 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | 10:23::ffff/128 | 10:23::ffff
|
200
|
+
(1 row)
|
201
|
+
|
202
|
+
select * from inet_val('::ffff:1.2.3.4'::cidr);
|
203
|
+
host | abbrev | masklen | network | netmask | first | last
|
204
|
+
----------------+--------------------+---------+--------------------+-----------------------------------------+--------------------+----------------
|
205
|
+
::ffff:1.2.3.4 | ::ffff:1.2.3.4/128 | 128 | ::ffff:1.2.3.4/128 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | ::ffff:1.2.3.4/128 | ::ffff:1.2.3.4
|
206
|
+
(1 row)
|
207
|
+
|
208
|
+
select * from inet_val('::4.3.2.1/24'::inet);
|
209
|
+
host | abbrev | masklen | network | netmask | first | last
|
210
|
+
-----------+--------------+---------+---------+-------------+-------+------------------------------------
|
211
|
+
::4.3.2.1 | ::4.3.2.1/24 | 24 | ::/24 | ffff:ff00:: | ::/24 | 0:ff:ffff:ffff:ffff:ffff:ffff:ffff
|
212
|
+
(1 row)
|
213
|
+
|
214
|
+
create or replace function mac_cmp(macaddr, macaddr) returns int as '
|
215
|
+
args[0] <=> args[1]
|
216
|
+
' language 'plruby';
|
217
|
+
select mac_cmp('00:07:E9:85:3E:C5'::macaddr, '00:E0:29:3E:E7:25'::macaddr);
|
218
|
+
mac_cmp
|
219
|
+
---------
|
220
|
+
-1
|
221
|
+
(1 row)
|
222
|
+
|
223
|
+
create or replace function mac_trunc(macaddr) returns macaddr as '
|
224
|
+
args[0].truncate
|
225
|
+
' language 'plruby';
|
226
|
+
select mac_trunc('00:07:E9:85:3E:C5'::macaddr);
|
227
|
+
mac_trunc
|
228
|
+
-------------------
|
229
|
+
00:07:e9:00:00:00
|
230
|
+
(1 row)
|
231
|
+
|
232
|
+
select mac_trunc('00:E0:29:3E:E7:25'::macaddr);
|
233
|
+
mac_trunc
|
234
|
+
-------------------
|
235
|
+
00:e0:29:00:00:00
|
236
|
+
(1 row)
|
237
|
+
|