globegit-postgresql-plruby 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/Changes +121 -0
  2. data/README.markdown +155 -0
  3. data/Rakefile +48 -0
  4. data/docs/plruby.rb +1931 -0
  5. data/ex_trans.sql +33 -0
  6. data/extconf.rb +267 -0
  7. data/plruby.html +1454 -0
  8. data/plruby.rd +1571 -0
  9. data/postgresql-plruby.gemspec +56 -0
  10. data/src/conversions.h +5 -0
  11. data/src/conversions/basic/conversions.h +25 -0
  12. data/src/conversions/basic/extconf.rb +8 -0
  13. data/src/conversions/basic/plruby_basic.c +357 -0
  14. data/src/conversions/bitstring/bitstring.sql +75 -0
  15. data/src/conversions/bitstring/conversions.h +15 -0
  16. data/src/conversions/bitstring/extconf.rb +8 -0
  17. data/src/conversions/bitstring/plruby_bitstring.c +579 -0
  18. data/src/conversions/convcommon.h +129 -0
  19. data/src/conversions/datetime/conversions.h +13 -0
  20. data/src/conversions/datetime/extconf.rb +8 -0
  21. data/src/conversions/datetime/plruby_datetime.c +269 -0
  22. data/src/conversions/geometry/conversions.h +37 -0
  23. data/src/conversions/geometry/extconf.rb +8 -0
  24. data/src/conversions/geometry/geometry.sql +196 -0
  25. data/src/conversions/geometry/plruby_geometry.c +2494 -0
  26. data/src/conversions/network/conversions.h +21 -0
  27. data/src/conversions/network/extconf.rb +8 -0
  28. data/src/conversions/network/network.sql +63 -0
  29. data/src/conversions/network/plruby_network.c +537 -0
  30. data/src/package.h +20 -0
  31. data/src/plpl.c +1708 -0
  32. data/src/plplan.c +893 -0
  33. data/src/plruby.c +1676 -0
  34. data/src/plruby.h +324 -0
  35. data/src/pltrans.c +388 -0
  36. data/test/conv_bitstring/b.rb +45 -0
  37. data/test/conv_bitstring/runtest +26 -0
  38. data/test/conv_bitstring/test.expected.73 +148 -0
  39. data/test/conv_bitstring/test.expected.74 +148 -0
  40. data/test/conv_bitstring/test.expected.80 +148 -0
  41. data/test/conv_bitstring/test.expected.81 +148 -0
  42. data/test/conv_bitstring/test.expected.82 +148 -0
  43. data/test/conv_bitstring/test.expected.83 +148 -0
  44. data/test/conv_bitstring/test.expected.84 +148 -0
  45. data/test/conv_bitstring/test.out +148 -0
  46. data/test/conv_bitstring/test_mklang.sql +8 -0
  47. data/test/conv_bitstring/test_queries.sql +63 -0
  48. data/test/conv_bitstring/test_queries.sql.in +63 -0
  49. data/test/conv_geometry/b.rb +45 -0
  50. data/test/conv_geometry/runtest +26 -0
  51. data/test/conv_geometry/test.expected.73 +265 -0
  52. data/test/conv_geometry/test.expected.74 +265 -0
  53. data/test/conv_geometry/test.expected.80 +265 -0
  54. data/test/conv_geometry/test.expected.81 +265 -0
  55. data/test/conv_geometry/test.expected.82 +265 -0
  56. data/test/conv_geometry/test.expected.83 +265 -0
  57. data/test/conv_geometry/test.expected.84 +265 -0
  58. data/test/conv_geometry/test.out +265 -0
  59. data/test/conv_geometry/test_mklang.sql +8 -0
  60. data/test/conv_geometry/test_queries.sql +194 -0
  61. data/test/conv_geometry/test_queries.sql.in +194 -0
  62. data/test/conv_network/b.rb +45 -0
  63. data/test/conv_network/runtest +26 -0
  64. data/test/conv_network/test.expected.73 +213 -0
  65. data/test/conv_network/test.expected.74 +237 -0
  66. data/test/conv_network/test.expected.80 +237 -0
  67. data/test/conv_network/test.expected.81 +237 -0
  68. data/test/conv_network/test.expected.82 +237 -0
  69. data/test/conv_network/test.expected.83 +237 -0
  70. data/test/conv_network/test.expected.84 +237 -0
  71. data/test/conv_network/test.out +237 -0
  72. data/test/conv_network/test_mklang.sql +8 -0
  73. data/test/conv_network/test_queries.sql +60 -0
  74. data/test/conv_network/test_queries.sql.in +60 -0
  75. data/test/plp/b.rb +34 -0
  76. data/test/plp/runtest +29 -0
  77. data/test/plp/test.expected.73 +472 -0
  78. data/test/plp/test.expected.74 +472 -0
  79. data/test/plp/test.expected.75 +472 -0
  80. data/test/plp/test.expected.80 +472 -0
  81. data/test/plp/test.expected.81 +472 -0
  82. data/test/plp/test.expected.82 +472 -0
  83. data/test/plp/test.expected.83 +472 -0
  84. data/test/plp/test.expected.84 +472 -0
  85. data/test/plp/test.out +472 -0
  86. data/test/plp/test_mklang.sql +8 -0
  87. data/test/plp/test_queries.sql +273 -0
  88. data/test/plp/test_setup.sql +931 -0
  89. data/test/plp/test_setup.sql.in +931 -0
  90. data/test/plt/b.rb +34 -0
  91. data/test/plt/runtest +29 -0
  92. data/test/plt/test.expected.73 +178 -0
  93. data/test/plt/test.expected.74 +178 -0
  94. data/test/plt/test.expected.75 +178 -0
  95. data/test/plt/test.expected.80 +178 -0
  96. data/test/plt/test.expected.81 +178 -0
  97. data/test/plt/test.expected.82 +178 -0
  98. data/test/plt/test.expected.83 +164 -0
  99. data/test/plt/test.expected.84 +168 -0
  100. data/test/plt/test.out +168 -0
  101. data/test/plt/test_mklang.sql +8 -0
  102. data/test/plt/test_queries.sql +72 -0
  103. data/test/plt/test_setup.sql +252 -0
  104. data/test/plt/test_setup.sql.in +252 -0
  105. data/test/range/b.rb +45 -0
  106. data/test/range/runtest +26 -0
  107. data/test/range/test.expected.73 +396 -0
  108. data/test/range/test.expected.73.in +396 -0
  109. data/test/range/test.expected.74 +396 -0
  110. data/test/range/test.expected.74.in +396 -0
  111. data/test/range/test.expected.75 +396 -0
  112. data/test/range/test.expected.75.in +396 -0
  113. data/test/range/test.expected.80 +396 -0
  114. data/test/range/test.expected.81 +397 -0
  115. data/test/range/test.expected.82 +397 -0
  116. data/test/range/test.expected.83 +397 -0
  117. data/test/range/test.expected.84 +399 -0
  118. data/test/range/test.out +399 -0
  119. data/test/range/test_mklang.sql +8 -0
  120. data/test/range/test_queries.sql +249 -0
  121. data/test/range/test_queries.sql.in +249 -0
  122. 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.0/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.0/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 | 255.255.255.255 | 192.168.1.226 | 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.0/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.0/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.0/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.0/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.0.0.0/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 | 10.0.0.0 | 255.255.255.255 | 10.0.0.0 | 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 | 10.1.2.3 | 255.255.255.255 | 10.1.2.3 | 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 | 255.255.255.255 | 10.1.2.3 | 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.0/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.0.0/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.0.0.0/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.0.0.0/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.0.0.0/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 | 10:23::f1 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | 10:23::f1 | 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 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | 10:23::ffff | 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 | ::ffff:1.2.3.4 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | ::ffff:1.2.3.4 | ::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,8 @@
1
+
2
+ create function plruby_call_handler() returns language_handler
3
+ as '/home/dberger/Repositories/postgresql-plruby/src/plruby.so'
4
+ language 'C';
5
+
6
+ create trusted procedural language 'plruby'
7
+ handler plruby_call_handler
8
+ lancompiler 'PL/Ruby';
@@ -0,0 +1,60 @@
1
+ create table pl_inet (
2
+ host text, abbrev text, masklen int,
3
+ network inet, netmask inet, first inet, last inet
4
+ );
5
+
6
+
7
+ create or replace function inet_val(inet) returns pl_inet as '
8
+ a = args[0]
9
+ [a.host, a.abbrev, a.masklen, a.network, a.netmask,
10
+ a.first, a.last]
11
+ ' language 'plruby';
12
+
13
+
14
+ select * from inet_val('192.168.1'::cidr);
15
+ select * from inet_val('192.168.1.226/24'::inet);
16
+ select * from inet_val('192.168.1.0/24'::cidr);
17
+ select * from inet_val('192.168.1.226'::inet);
18
+ select * from inet_val('192.168.1'::cidr);
19
+ select * from inet_val('192.168.1.0/24'::inet);
20
+ select * from inet_val('192.168.1'::cidr);
21
+ select * from inet_val('192.168.1.0/25'::inet);
22
+ select * from inet_val('192.168.1'::cidr);
23
+ select * from inet_val('192.168.1.255/24'::inet);
24
+ select * from inet_val('192.168.1'::cidr);
25
+ select * from inet_val('192.168.1.255/25'::inet);
26
+ select * from inet_val('10'::cidr);
27
+ select * from inet_val('10.1.2.3/8'::inet);
28
+ select * from inet_val('10.0.0.0'::cidr);
29
+ select * from inet_val('10.1.2.3/8'::inet);
30
+ select * from inet_val('10.1.2.3'::cidr);
31
+ select * from inet_val('10.1.2.3/32'::inet);
32
+ select * from inet_val('10.1.2'::cidr);
33
+ select * from inet_val('10.1.2.3/24'::inet);
34
+ select * from inet_val('10.1'::cidr);
35
+ select * from inet_val('10.1.2.3/16'::inet);
36
+ select * from inet_val('10'::cidr);
37
+ select * from inet_val('10.1.2.3/8'::inet);
38
+ select * from inet_val('10'::cidr);
39
+ select * from inet_val('11.1.2.3/8'::inet);
40
+ select * from inet_val('10'::cidr);
41
+ select * from inet_val('9.1.2.3/8'::inet);
42
+ select * from inet_val('10:23::f1'::cidr);
43
+ select * from inet_val('10:23::f1/64'::inet);
44
+ select * from inet_val('10:23::8000/113'::cidr);
45
+ select * from inet_val('10:23::ffff'::inet);
46
+ select * from inet_val('::ffff:1.2.3.4'::cidr);
47
+ select * from inet_val('::4.3.2.1/24'::inet);
48
+
49
+ create or replace function mac_cmp(macaddr, macaddr) returns int as '
50
+ args[0] <=> args[1]
51
+ ' language 'plruby';
52
+
53
+ select mac_cmp('00:07:E9:85:3E:C5'::macaddr, '00:E0:29:3E:E7:25'::macaddr);
54
+
55
+ create or replace function mac_trunc(macaddr) returns macaddr as '
56
+ args[0].truncate
57
+ ' language 'plruby';
58
+
59
+ select mac_trunc('00:07:E9:85:3E:C5'::macaddr);
60
+ select mac_trunc('00:E0:29:3E:E7:25'::macaddr);
@@ -0,0 +1,60 @@
1
+ create table pl_inet (
2
+ host text, abbrev text, masklen int,
3
+ network inet, netmask inet, first inet, last inet
4
+ );
5
+
6
+
7
+ create or replace function inet_val(inet) returns pl_inet as '
8
+ a = args[0]
9
+ [a.host, a.abbrev, a.masklen, a.network, a.netmask,
10
+ a.first, a.last]
11
+ ' language 'plruby';
12
+
13
+
14
+ select * from inet_val('192.168.1'::cidr);
15
+ select * from inet_val('192.168.1.226/24'::inet);
16
+ select * from inet_val('192.168.1.0/24'::cidr);
17
+ select * from inet_val('192.168.1.226'::inet);
18
+ select * from inet_val('192.168.1'::cidr);
19
+ select * from inet_val('192.168.1.0/24'::inet);
20
+ select * from inet_val('192.168.1'::cidr);
21
+ select * from inet_val('192.168.1.0/25'::inet);
22
+ select * from inet_val('192.168.1'::cidr);
23
+ select * from inet_val('192.168.1.255/24'::inet);
24
+ select * from inet_val('192.168.1'::cidr);
25
+ select * from inet_val('192.168.1.255/25'::inet);
26
+ select * from inet_val('10'::cidr);
27
+ select * from inet_val('10.1.2.3/8'::inet);
28
+ select * from inet_val('10.0.0.0'::cidr);
29
+ select * from inet_val('10.1.2.3/8'::inet);
30
+ select * from inet_val('10.1.2.3'::cidr);
31
+ select * from inet_val('10.1.2.3/32'::inet);
32
+ select * from inet_val('10.1.2'::cidr);
33
+ select * from inet_val('10.1.2.3/24'::inet);
34
+ select * from inet_val('10.1'::cidr);
35
+ select * from inet_val('10.1.2.3/16'::inet);
36
+ select * from inet_val('10'::cidr);
37
+ select * from inet_val('10.1.2.3/8'::inet);
38
+ select * from inet_val('10'::cidr);
39
+ select * from inet_val('11.1.2.3/8'::inet);
40
+ select * from inet_val('10'::cidr);
41
+ select * from inet_val('9.1.2.3/8'::inet);
42
+ select * from inet_val('10:23::f1'::cidr);
43
+ select * from inet_val('10:23::f1/64'::inet);
44
+ select * from inet_val('10:23::8000/113'::cidr);
45
+ select * from inet_val('10:23::ffff'::inet);
46
+ select * from inet_val('::ffff:1.2.3.4'::cidr);
47
+ select * from inet_val('::4.3.2.1/24'::inet);
48
+
49
+ create or replace function mac_cmp(macaddr, macaddr) returns int as '
50
+ args[0] <=> args[1]
51
+ ' language 'plruby';
52
+
53
+ select mac_cmp('00:07:E9:85:3E:C5'::macaddr, '00:E0:29:3E:E7:25'::macaddr);
54
+
55
+ create or replace function mac_trunc(macaddr) returns macaddr as '
56
+ args[0].truncate
57
+ ' language 'plruby';
58
+
59
+ select mac_trunc('00:07:E9:85:3E:C5'::macaddr);
60
+ select mac_trunc('00:E0:29:3E:E7:25'::macaddr);
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby
2
+ require 'rbconfig'
3
+ include Config
4
+ pwd = Dir.pwd
5
+ pwd.sub!(%r{[^/]+/[^/]+$}, "")
6
+
7
+ language, extension = 'C', '_new_trigger'
8
+ opaque = 'language_handler'
9
+
10
+ version = ARGV[0].to_i
11
+ suffix = ARGV[1].to_s
12
+
13
+ begin
14
+ f = File.new("test_setup.sql", "w")
15
+ IO.foreach("test_setup.sql.in") do |x|
16
+ x.gsub!(/language\s+'plruby'/i, "language 'plruby#{suffix}'")
17
+ f.print x
18
+ end
19
+ f.close
20
+ f = File.new("test_mklang.sql", "w")
21
+ f.print <<EOF
22
+
23
+ create function plruby#{suffix}_call_handler() returns #{opaque}
24
+ as '#{pwd}src/plruby#{suffix}.#{CONFIG["DLEXT"]}'
25
+ language '#{language}';
26
+
27
+ create trusted procedural language 'plruby#{suffix}'
28
+ handler plruby#{suffix}_call_handler
29
+ lancompiler 'PL/Ruby';
30
+ EOF
31
+ f.close
32
+ rescue
33
+ raise "Why I can't write #$!"
34
+ end
@@ -0,0 +1,29 @@
1
+ #!/bin/sh
2
+
3
+ DBNAME=plruby_test
4
+ export DBNAME
5
+
6
+ sleep 1
7
+ echo "**** Destroy old database $DBNAME ****"
8
+ dropdb $DBNAME
9
+
10
+ echo "**** Create test database $DBNAME ****"
11
+ createdb $DBNAME
12
+
13
+ echo "**** Create procedural language plruby$2 ****"
14
+ "${RUBY-ruby}" b.rb $*
15
+ psql -q -n -X $DBNAME < test_mklang.sql
16
+
17
+ echo "**** Create tables, functions and triggers ****"
18
+ psql -q -n -X $DBNAME < test_setup.sql
19
+
20
+ echo "**** Running test queries ****"
21
+ psql -q -n -X -e $DBNAME < test_queries.sql > test.out 2>&1
22
+
23
+ if cmp -s test.expected.$1 test.out; then
24
+ echo " Tests passed O.K."
25
+ else
26
+ echo " Tests failed - look at diffs between"
27
+ echo " test.expected.$1 and test.out"
28
+ fi
29
+
@@ -0,0 +1,472 @@
1
+ insert into Room values ('001', 'Entrance');
2
+ insert into Room values ('002', 'Office');
3
+ insert into Room values ('003', 'Office');
4
+ insert into Room values ('004', 'Technical');
5
+ insert into Room values ('101', 'Office');
6
+ insert into Room values ('102', 'Conference');
7
+ insert into Room values ('103', 'Restroom');
8
+ insert into Room values ('104', 'Technical');
9
+ insert into Room values ('105', 'Office');
10
+ insert into Room values ('106', 'Office');
11
+ insert into WSlot values ('WS.001.1a', '001', '', '');
12
+ insert into WSlot values ('WS.001.1b', '001', '', '');
13
+ insert into WSlot values ('WS.001.2a', '001', '', '');
14
+ insert into WSlot values ('WS.001.2b', '001', '', '');
15
+ insert into WSlot values ('WS.001.3a', '001', '', '');
16
+ insert into WSlot values ('WS.001.3b', '001', '', '');
17
+ insert into WSlot values ('WS.002.1a', '002', '', '');
18
+ insert into WSlot values ('WS.002.1b', '002', '', '');
19
+ insert into WSlot values ('WS.002.2a', '002', '', '');
20
+ insert into WSlot values ('WS.002.2b', '002', '', '');
21
+ insert into WSlot values ('WS.002.3a', '002', '', '');
22
+ insert into WSlot values ('WS.002.3b', '002', '', '');
23
+ insert into WSlot values ('WS.003.1a', '003', '', '');
24
+ insert into WSlot values ('WS.003.1b', '003', '', '');
25
+ insert into WSlot values ('WS.003.2a', '003', '', '');
26
+ insert into WSlot values ('WS.003.2b', '003', '', '');
27
+ insert into WSlot values ('WS.003.3a', '003', '', '');
28
+ insert into WSlot values ('WS.003.3b', '003', '', '');
29
+ insert into WSlot values ('WS.101.1a', '101', '', '');
30
+ insert into WSlot values ('WS.101.1b', '101', '', '');
31
+ insert into WSlot values ('WS.101.2a', '101', '', '');
32
+ insert into WSlot values ('WS.101.2b', '101', '', '');
33
+ insert into WSlot values ('WS.101.3a', '101', '', '');
34
+ insert into WSlot values ('WS.101.3b', '101', '', '');
35
+ insert into WSlot values ('WS.102.1a', '102', '', '');
36
+ insert into WSlot values ('WS.102.1b', '102', '', '');
37
+ insert into WSlot values ('WS.102.2a', '102', '', '');
38
+ insert into WSlot values ('WS.102.2b', '102', '', '');
39
+ insert into WSlot values ('WS.102.3a', '102', '', '');
40
+ insert into WSlot values ('WS.102.3b', '102', '', '');
41
+ insert into WSlot values ('WS.105.1a', '105', '', '');
42
+ insert into WSlot values ('WS.105.1b', '105', '', '');
43
+ insert into WSlot values ('WS.105.2a', '105', '', '');
44
+ insert into WSlot values ('WS.105.2b', '105', '', '');
45
+ insert into WSlot values ('WS.105.3a', '105', '', '');
46
+ insert into WSlot values ('WS.105.3b', '105', '', '');
47
+ insert into WSlot values ('WS.106.1a', '106', '', '');
48
+ insert into WSlot values ('WS.106.1b', '106', '', '');
49
+ insert into WSlot values ('WS.106.2a', '106', '', '');
50
+ insert into WSlot values ('WS.106.2b', '106', '', '');
51
+ insert into WSlot values ('WS.106.3a', '106', '', '');
52
+ insert into WSlot values ('WS.106.3b', '106', '', '');
53
+ insert into PField values ('PF0_1', 'Wallslots basement');
54
+ insert into PSlot values ('PS.base.a1', 'PF0_1', '', '');
55
+ insert into PSlot values ('PS.base.a2', 'PF0_1', '', '');
56
+ insert into PSlot values ('PS.base.a3', 'PF0_1', '', '');
57
+ insert into PSlot values ('PS.base.a4', 'PF0_1', '', '');
58
+ insert into PSlot values ('PS.base.a5', 'PF0_1', '', '');
59
+ insert into PSlot values ('PS.base.a6', 'PF0_1', '', '');
60
+ insert into PSlot values ('PS.base.b1', 'PF0_1', '', 'WS.002.1a');
61
+ insert into PSlot values ('PS.base.b2', 'PF0_1', '', 'WS.002.1b');
62
+ insert into PSlot values ('PS.base.b3', 'PF0_1', '', 'WS.002.2a');
63
+ insert into PSlot values ('PS.base.b4', 'PF0_1', '', 'WS.002.2b');
64
+ insert into PSlot values ('PS.base.b5', 'PF0_1', '', 'WS.002.3a');
65
+ insert into PSlot values ('PS.base.b6', 'PF0_1', '', 'WS.002.3b');
66
+ insert into PSlot values ('PS.base.c1', 'PF0_1', '', 'WS.003.1a');
67
+ insert into PSlot values ('PS.base.c2', 'PF0_1', '', 'WS.003.1b');
68
+ insert into PSlot values ('PS.base.c3', 'PF0_1', '', 'WS.003.2a');
69
+ insert into PSlot values ('PS.base.c4', 'PF0_1', '', 'WS.003.2b');
70
+ insert into PSlot values ('PS.base.c5', 'PF0_1', '', 'WS.003.3a');
71
+ insert into PSlot values ('PS.base.c6', 'PF0_1', '', 'WS.003.3b');
72
+ insert into PField values ('PF0_X', 'Phonelines basement');
73
+ insert into PSlot values ('PS.base.ta1', 'PF0_X', '', '');
74
+ insert into PSlot values ('PS.base.ta2', 'PF0_X', '', '');
75
+ insert into PSlot values ('PS.base.ta3', 'PF0_X', '', '');
76
+ insert into PSlot values ('PS.base.ta4', 'PF0_X', '', '');
77
+ insert into PSlot values ('PS.base.ta5', 'PF0_X', '', '');
78
+ insert into PSlot values ('PS.base.ta6', 'PF0_X', '', '');
79
+ insert into PSlot values ('PS.base.tb1', 'PF0_X', '', '');
80
+ insert into PSlot values ('PS.base.tb2', 'PF0_X', '', '');
81
+ insert into PSlot values ('PS.base.tb3', 'PF0_X', '', '');
82
+ insert into PSlot values ('PS.base.tb4', 'PF0_X', '', '');
83
+ insert into PSlot values ('PS.base.tb5', 'PF0_X', '', '');
84
+ insert into PSlot values ('PS.base.tb6', 'PF0_X', '', '');
85
+ insert into PField values ('PF1_1', 'Wallslots 1st floor');
86
+ insert into PSlot values ('PS.1st.a1', 'PF1_1', '', 'WS.101.1a');
87
+ insert into PSlot values ('PS.1st.a2', 'PF1_1', '', 'WS.101.1b');
88
+ insert into PSlot values ('PS.1st.a3', 'PF1_1', '', 'WS.101.2a');
89
+ insert into PSlot values ('PS.1st.a4', 'PF1_1', '', 'WS.101.2b');
90
+ insert into PSlot values ('PS.1st.a5', 'PF1_1', '', 'WS.101.3a');
91
+ insert into PSlot values ('PS.1st.a6', 'PF1_1', '', 'WS.101.3b');
92
+ insert into PSlot values ('PS.1st.b1', 'PF1_1', '', 'WS.102.1a');
93
+ insert into PSlot values ('PS.1st.b2', 'PF1_1', '', 'WS.102.1b');
94
+ insert into PSlot values ('PS.1st.b3', 'PF1_1', '', 'WS.102.2a');
95
+ insert into PSlot values ('PS.1st.b4', 'PF1_1', '', 'WS.102.2b');
96
+ insert into PSlot values ('PS.1st.b5', 'PF1_1', '', 'WS.102.3a');
97
+ insert into PSlot values ('PS.1st.b6', 'PF1_1', '', 'WS.102.3b');
98
+ insert into PSlot values ('PS.1st.c1', 'PF1_1', '', 'WS.105.1a');
99
+ insert into PSlot values ('PS.1st.c2', 'PF1_1', '', 'WS.105.1b');
100
+ insert into PSlot values ('PS.1st.c3', 'PF1_1', '', 'WS.105.2a');
101
+ insert into PSlot values ('PS.1st.c4', 'PF1_1', '', 'WS.105.2b');
102
+ insert into PSlot values ('PS.1st.c5', 'PF1_1', '', 'WS.105.3a');
103
+ insert into PSlot values ('PS.1st.c6', 'PF1_1', '', 'WS.105.3b');
104
+ insert into PSlot values ('PS.1st.d1', 'PF1_1', '', 'WS.106.1a');
105
+ insert into PSlot values ('PS.1st.d2', 'PF1_1', '', 'WS.106.1b');
106
+ insert into PSlot values ('PS.1st.d3', 'PF1_1', '', 'WS.106.2a');
107
+ insert into PSlot values ('PS.1st.d4', 'PF1_1', '', 'WS.106.2b');
108
+ insert into PSlot values ('PS.1st.d5', 'PF1_1', '', 'WS.106.3a');
109
+ insert into PSlot values ('PS.1st.d6', 'PF1_1', '', 'WS.106.3b');
110
+ update PSlot set backlink = 'WS.001.1a' where slotname = 'PS.base.a1';
111
+ update PSlot set backlink = 'WS.001.1b' where slotname = 'PS.base.a3';
112
+ select * from WSlot where roomno = '001' order by slotname;
113
+ slotname | roomno | slotlink | backlink
114
+ -----------+--------+----------+------------
115
+ WS.001.1a | 001 | | PS.base.a1
116
+ WS.001.1b | 001 | | PS.base.a3
117
+ WS.001.2a | 001 | |
118
+ WS.001.2b | 001 | |
119
+ WS.001.3a | 001 | |
120
+ WS.001.3b | 001 | |
121
+ (6 rows)
122
+
123
+ select * from PSlot where slotname ~ 'PS.base.a' order by slotname;
124
+ slotname | pfname | slotlink | backlink
125
+ ------------+--------+----------+-----------
126
+ PS.base.a1 | PF0_1 | | WS.001.1a
127
+ PS.base.a2 | PF0_1 | |
128
+ PS.base.a3 | PF0_1 | | WS.001.1b
129
+ PS.base.a4 | PF0_1 | |
130
+ PS.base.a5 | PF0_1 | |
131
+ PS.base.a6 | PF0_1 | |
132
+ (6 rows)
133
+
134
+ update PSlot set backlink = 'WS.001.2a' where slotname = 'PS.base.a3';
135
+ select * from WSlot where roomno = '001' order by slotname;
136
+ slotname | roomno | slotlink | backlink
137
+ -----------+--------+----------+------------
138
+ WS.001.1a | 001 | | PS.base.a1
139
+ WS.001.1b | 001 | |
140
+ WS.001.2a | 001 | | PS.base.a3
141
+ WS.001.2b | 001 | |
142
+ WS.001.3a | 001 | |
143
+ WS.001.3b | 001 | |
144
+ (6 rows)
145
+
146
+ select * from PSlot where slotname ~ 'PS.base.a' order by slotname;
147
+ slotname | pfname | slotlink | backlink
148
+ ------------+--------+----------+-----------
149
+ PS.base.a1 | PF0_1 | | WS.001.1a
150
+ PS.base.a2 | PF0_1 | |
151
+ PS.base.a3 | PF0_1 | | WS.001.2a
152
+ PS.base.a4 | PF0_1 | |
153
+ PS.base.a5 | PF0_1 | |
154
+ PS.base.a6 | PF0_1 | |
155
+ (6 rows)
156
+
157
+ update PSlot set backlink = 'WS.001.1b' where slotname = 'PS.base.a2';
158
+ select * from WSlot where roomno = '001' order by slotname;
159
+ slotname | roomno | slotlink | backlink
160
+ -----------+--------+----------+------------
161
+ WS.001.1a | 001 | | PS.base.a1
162
+ WS.001.1b | 001 | | PS.base.a2
163
+ WS.001.2a | 001 | | PS.base.a3
164
+ WS.001.2b | 001 | |
165
+ WS.001.3a | 001 | |
166
+ WS.001.3b | 001 | |
167
+ (6 rows)
168
+
169
+ select * from PSlot where slotname ~ 'PS.base.a' order by slotname;
170
+ slotname | pfname | slotlink | backlink
171
+ ------------+--------+----------+-----------
172
+ PS.base.a1 | PF0_1 | | WS.001.1a
173
+ PS.base.a2 | PF0_1 | | WS.001.1b
174
+ PS.base.a3 | PF0_1 | | WS.001.2a
175
+ PS.base.a4 | PF0_1 | |
176
+ PS.base.a5 | PF0_1 | |
177
+ PS.base.a6 | PF0_1 | |
178
+ (6 rows)
179
+
180
+ update WSlot set backlink = 'PS.base.a4' where slotname = 'WS.001.2b';
181
+ update WSlot set backlink = 'PS.base.a6' where slotname = 'WS.001.3a';
182
+ select * from WSlot where roomno = '001' order by slotname;
183
+ slotname | roomno | slotlink | backlink
184
+ -----------+--------+----------+------------
185
+ WS.001.1a | 001 | | PS.base.a1
186
+ WS.001.1b | 001 | | PS.base.a2
187
+ WS.001.2a | 001 | | PS.base.a3
188
+ WS.001.2b | 001 | | PS.base.a4
189
+ WS.001.3a | 001 | | PS.base.a6
190
+ WS.001.3b | 001 | |
191
+ (6 rows)
192
+
193
+ select * from PSlot where slotname ~ 'PS.base.a' order by slotname;
194
+ slotname | pfname | slotlink | backlink
195
+ ------------+--------+----------+-----------
196
+ PS.base.a1 | PF0_1 | | WS.001.1a
197
+ PS.base.a2 | PF0_1 | | WS.001.1b
198
+ PS.base.a3 | PF0_1 | | WS.001.2a
199
+ PS.base.a4 | PF0_1 | | WS.001.2b
200
+ PS.base.a5 | PF0_1 | |
201
+ PS.base.a6 | PF0_1 | | WS.001.3a
202
+ (6 rows)
203
+
204
+ update WSlot set backlink = 'PS.base.a6' where slotname = 'WS.001.3b';
205
+ select * from WSlot where roomno = '001' order by slotname;
206
+ slotname | roomno | slotlink | backlink
207
+ -----------+--------+----------+------------
208
+ WS.001.1a | 001 | | PS.base.a1
209
+ WS.001.1b | 001 | | PS.base.a2
210
+ WS.001.2a | 001 | | PS.base.a3
211
+ WS.001.2b | 001 | | PS.base.a4
212
+ WS.001.3a | 001 | |
213
+ WS.001.3b | 001 | | PS.base.a6
214
+ (6 rows)
215
+
216
+ select * from PSlot where slotname ~ 'PS.base.a' order by slotname;
217
+ slotname | pfname | slotlink | backlink
218
+ ------------+--------+----------+-----------
219
+ PS.base.a1 | PF0_1 | | WS.001.1a
220
+ PS.base.a2 | PF0_1 | | WS.001.1b
221
+ PS.base.a3 | PF0_1 | | WS.001.2a
222
+ PS.base.a4 | PF0_1 | | WS.001.2b
223
+ PS.base.a5 | PF0_1 | |
224
+ PS.base.a6 | PF0_1 | | WS.001.3b
225
+ (6 rows)
226
+
227
+ update WSlot set backlink = 'PS.base.a5' where slotname = 'WS.001.3a';
228
+ select * from WSlot where roomno = '001' order by slotname;
229
+ slotname | roomno | slotlink | backlink
230
+ -----------+--------+----------+------------
231
+ WS.001.1a | 001 | | PS.base.a1
232
+ WS.001.1b | 001 | | PS.base.a2
233
+ WS.001.2a | 001 | | PS.base.a3
234
+ WS.001.2b | 001 | | PS.base.a4
235
+ WS.001.3a | 001 | | PS.base.a5
236
+ WS.001.3b | 001 | | PS.base.a6
237
+ (6 rows)
238
+
239
+ select * from PSlot where slotname ~ 'PS.base.a' order by slotname;
240
+ slotname | pfname | slotlink | backlink
241
+ ------------+--------+----------+-----------
242
+ PS.base.a1 | PF0_1 | | WS.001.1a
243
+ PS.base.a2 | PF0_1 | | WS.001.1b
244
+ PS.base.a3 | PF0_1 | | WS.001.2a
245
+ PS.base.a4 | PF0_1 | | WS.001.2b
246
+ PS.base.a5 | PF0_1 | | WS.001.3a
247
+ PS.base.a6 | PF0_1 | | WS.001.3b
248
+ (6 rows)
249
+
250
+ insert into PField values ('PF1_2', 'Phonelines 1st floor');
251
+ insert into PSlot values ('PS.1st.ta1', 'PF1_2', '', '');
252
+ insert into PSlot values ('PS.1st.ta2', 'PF1_2', '', '');
253
+ insert into PSlot values ('PS.1st.ta3', 'PF1_2', '', '');
254
+ insert into PSlot values ('PS.1st.ta4', 'PF1_2', '', '');
255
+ insert into PSlot values ('PS.1st.ta5', 'PF1_2', '', '');
256
+ insert into PSlot values ('PS.1st.ta6', 'PF1_2', '', '');
257
+ insert into PSlot values ('PS.1st.tb1', 'PF1_2', '', '');
258
+ insert into PSlot values ('PS.1st.tb2', 'PF1_2', '', '');
259
+ insert into PSlot values ('PS.1st.tb3', 'PF1_2', '', '');
260
+ insert into PSlot values ('PS.1st.tb4', 'PF1_2', '', '');
261
+ insert into PSlot values ('PS.1st.tb5', 'PF1_2', '', '');
262
+ insert into PSlot values ('PS.1st.tb6', 'PF1_2', '', '');
263
+ update PField set name = 'PF0_2' where name = 'PF0_X';
264
+ select * from PSlot order by slotname;
265
+ slotname | pfname | slotlink | backlink
266
+ -------------+--------+----------+-----------
267
+ PS.1st.a1 | PF1_1 | | WS.101.1a
268
+ PS.1st.a2 | PF1_1 | | WS.101.1b
269
+ PS.1st.a3 | PF1_1 | | WS.101.2a
270
+ PS.1st.a4 | PF1_1 | | WS.101.2b
271
+ PS.1st.a5 | PF1_1 | | WS.101.3a
272
+ PS.1st.a6 | PF1_1 | | WS.101.3b
273
+ PS.1st.b1 | PF1_1 | | WS.102.1a
274
+ PS.1st.b2 | PF1_1 | | WS.102.1b
275
+ PS.1st.b3 | PF1_1 | | WS.102.2a
276
+ PS.1st.b4 | PF1_1 | | WS.102.2b
277
+ PS.1st.b5 | PF1_1 | | WS.102.3a
278
+ PS.1st.b6 | PF1_1 | | WS.102.3b
279
+ PS.1st.c1 | PF1_1 | | WS.105.1a
280
+ PS.1st.c2 | PF1_1 | | WS.105.1b
281
+ PS.1st.c3 | PF1_1 | | WS.105.2a
282
+ PS.1st.c4 | PF1_1 | | WS.105.2b
283
+ PS.1st.c5 | PF1_1 | | WS.105.3a
284
+ PS.1st.c6 | PF1_1 | | WS.105.3b
285
+ PS.1st.d1 | PF1_1 | | WS.106.1a
286
+ PS.1st.d2 | PF1_1 | | WS.106.1b
287
+ PS.1st.d3 | PF1_1 | | WS.106.2a
288
+ PS.1st.d4 | PF1_1 | | WS.106.2b
289
+ PS.1st.d5 | PF1_1 | | WS.106.3a
290
+ PS.1st.d6 | PF1_1 | | WS.106.3b
291
+ PS.1st.ta1 | PF1_2 | |
292
+ PS.1st.ta2 | PF1_2 | |
293
+ PS.1st.ta3 | PF1_2 | |
294
+ PS.1st.ta4 | PF1_2 | |
295
+ PS.1st.ta5 | PF1_2 | |
296
+ PS.1st.ta6 | PF1_2 | |
297
+ PS.1st.tb1 | PF1_2 | |
298
+ PS.1st.tb2 | PF1_2 | |
299
+ PS.1st.tb3 | PF1_2 | |
300
+ PS.1st.tb4 | PF1_2 | |
301
+ PS.1st.tb5 | PF1_2 | |
302
+ PS.1st.tb6 | PF1_2 | |
303
+ PS.base.a1 | PF0_1 | | WS.001.1a
304
+ PS.base.a2 | PF0_1 | | WS.001.1b
305
+ PS.base.a3 | PF0_1 | | WS.001.2a
306
+ PS.base.a4 | PF0_1 | | WS.001.2b
307
+ PS.base.a5 | PF0_1 | | WS.001.3a
308
+ PS.base.a6 | PF0_1 | | WS.001.3b
309
+ PS.base.b1 | PF0_1 | | WS.002.1a
310
+ PS.base.b2 | PF0_1 | | WS.002.1b
311
+ PS.base.b3 | PF0_1 | | WS.002.2a
312
+ PS.base.b4 | PF0_1 | | WS.002.2b
313
+ PS.base.b5 | PF0_1 | | WS.002.3a
314
+ PS.base.b6 | PF0_1 | | WS.002.3b
315
+ PS.base.c1 | PF0_1 | | WS.003.1a
316
+ PS.base.c2 | PF0_1 | | WS.003.1b
317
+ PS.base.c3 | PF0_1 | | WS.003.2a
318
+ PS.base.c4 | PF0_1 | | WS.003.2b
319
+ PS.base.c5 | PF0_1 | | WS.003.3a
320
+ PS.base.c6 | PF0_1 | | WS.003.3b
321
+ PS.base.ta1 | PF0_2 | |
322
+ PS.base.ta2 | PF0_2 | |
323
+ PS.base.ta3 | PF0_2 | |
324
+ PS.base.ta4 | PF0_2 | |
325
+ PS.base.ta5 | PF0_2 | |
326
+ PS.base.ta6 | PF0_2 | |
327
+ PS.base.tb1 | PF0_2 | |
328
+ PS.base.tb2 | PF0_2 | |
329
+ PS.base.tb3 | PF0_2 | |
330
+ PS.base.tb4 | PF0_2 | |
331
+ PS.base.tb5 | PF0_2 | |
332
+ PS.base.tb6 | PF0_2 | |
333
+ (66 rows)
334
+
335
+ select * from WSlot order by slotname;
336
+ slotname | roomno | slotlink | backlink
337
+ -----------+--------+----------+------------
338
+ WS.001.1a | 001 | | PS.base.a1
339
+ WS.001.1b | 001 | | PS.base.a2
340
+ WS.001.2a | 001 | | PS.base.a3
341
+ WS.001.2b | 001 | | PS.base.a4
342
+ WS.001.3a | 001 | | PS.base.a5
343
+ WS.001.3b | 001 | | PS.base.a6
344
+ WS.002.1a | 002 | | PS.base.b1
345
+ WS.002.1b | 002 | | PS.base.b2
346
+ WS.002.2a | 002 | | PS.base.b3
347
+ WS.002.2b | 002 | | PS.base.b4
348
+ WS.002.3a | 002 | | PS.base.b5
349
+ WS.002.3b | 002 | | PS.base.b6
350
+ WS.003.1a | 003 | | PS.base.c1
351
+ WS.003.1b | 003 | | PS.base.c2
352
+ WS.003.2a | 003 | | PS.base.c3
353
+ WS.003.2b | 003 | | PS.base.c4
354
+ WS.003.3a | 003 | | PS.base.c5
355
+ WS.003.3b | 003 | | PS.base.c6
356
+ WS.101.1a | 101 | | PS.1st.a1
357
+ WS.101.1b | 101 | | PS.1st.a2
358
+ WS.101.2a | 101 | | PS.1st.a3
359
+ WS.101.2b | 101 | | PS.1st.a4
360
+ WS.101.3a | 101 | | PS.1st.a5
361
+ WS.101.3b | 101 | | PS.1st.a6
362
+ WS.102.1a | 102 | | PS.1st.b1
363
+ WS.102.1b | 102 | | PS.1st.b2
364
+ WS.102.2a | 102 | | PS.1st.b3
365
+ WS.102.2b | 102 | | PS.1st.b4
366
+ WS.102.3a | 102 | | PS.1st.b5
367
+ WS.102.3b | 102 | | PS.1st.b6
368
+ WS.105.1a | 105 | | PS.1st.c1
369
+ WS.105.1b | 105 | | PS.1st.c2
370
+ WS.105.2a | 105 | | PS.1st.c3
371
+ WS.105.2b | 105 | | PS.1st.c4
372
+ WS.105.3a | 105 | | PS.1st.c5
373
+ WS.105.3b | 105 | | PS.1st.c6
374
+ WS.106.1a | 106 | | PS.1st.d1
375
+ WS.106.1b | 106 | | PS.1st.d2
376
+ WS.106.2a | 106 | | PS.1st.d3
377
+ WS.106.2b | 106 | | PS.1st.d4
378
+ WS.106.3a | 106 | | PS.1st.d5
379
+ WS.106.3b | 106 | | PS.1st.d6
380
+ (42 rows)
381
+
382
+ insert into PLine values ('PL.001', '-0', 'Central call', 'PS.base.ta1');
383
+ insert into PLine values ('PL.002', '-101', '', 'PS.base.ta2');
384
+ insert into PLine values ('PL.003', '-102', '', 'PS.base.ta3');
385
+ insert into PLine values ('PL.004', '-103', '', 'PS.base.ta5');
386
+ insert into PLine values ('PL.005', '-104', '', 'PS.base.ta6');
387
+ insert into PLine values ('PL.006', '-106', '', 'PS.base.tb2');
388
+ insert into PLine values ('PL.007', '-108', '', 'PS.base.tb3');
389
+ insert into PLine values ('PL.008', '-109', '', 'PS.base.tb4');
390
+ insert into PLine values ('PL.009', '-121', '', 'PS.base.tb5');
391
+ insert into PLine values ('PL.010', '-122', '', 'PS.base.tb6');
392
+ insert into PLine values ('PL.015', '-134', '', 'PS.1st.ta1');
393
+ insert into PLine values ('PL.016', '-137', '', 'PS.1st.ta3');
394
+ insert into PLine values ('PL.017', '-139', '', 'PS.1st.ta4');
395
+ insert into PLine values ('PL.018', '-362', '', 'PS.1st.tb1');
396
+ insert into PLine values ('PL.019', '-363', '', 'PS.1st.tb2');
397
+ insert into PLine values ('PL.020', '-364', '', 'PS.1st.tb3');
398
+ insert into PLine values ('PL.021', '-365', '', 'PS.1st.tb5');
399
+ insert into PLine values ('PL.022', '-367', '', 'PS.1st.tb6');
400
+ insert into PLine values ('PL.028', '-501', 'Fax entrance', 'PS.base.ta2');
401
+ insert into PLine values ('PL.029', '-502', 'Fax 1st floor', 'PS.1st.ta1');
402
+ insert into PHone values ('PH.hc001', 'Hicom standard', 'WS.001.1a');
403
+ update PSlot set slotlink = 'PS.base.ta1' where slotname = 'PS.base.a1';
404
+ insert into PHone values ('PH.hc002', 'Hicom standard', 'WS.002.1a');
405
+ update PSlot set slotlink = 'PS.base.ta5' where slotname = 'PS.base.b1';
406
+ insert into PHone values ('PH.hc003', 'Hicom standard', 'WS.002.2a');
407
+ update PSlot set slotlink = 'PS.base.tb2' where slotname = 'PS.base.b3';
408
+ insert into PHone values ('PH.fax001', 'Canon fax', 'WS.001.2a');
409
+ update PSlot set slotlink = 'PS.base.ta2' where slotname = 'PS.base.a3';
410
+ insert into Hub values ('base.hub1', 'Patchfield PF0_1 hub', 16);
411
+ insert into System values ('orion', 'PC');
412
+ insert into IFace values ('IF', 'orion', 'eth0', 'WS.002.1b');
413
+ update PSlot set slotlink = 'HS.base.hub1.1' where slotname = 'PS.base.b2';
414
+ select * from PField_v1 where pfname = 'PF0_1' order by slotname;
415
+ pfname | slotname | backside | patch
416
+ --------+------------+----------------------------------------------------------+-----------------------------------------------
417
+ PF0_1 | PS.base.a1 | WS.001.1a in room 001 -> Phone PH.hc001 (Hicom standard) | PS.base.ta1 -> Phone line -0 (Central call)
418
+ PF0_1 | PS.base.a2 | WS.001.1b in room 001 -> - | -
419
+ PF0_1 | PS.base.a3 | WS.001.2a in room 001 -> Phone PH.fax001 (Canon fax) | PS.base.ta2 -> Phone line -501 (Fax entrance)
420
+ PF0_1 | PS.base.a4 | WS.001.2b in room 001 -> - | -
421
+ PF0_1 | PS.base.a5 | WS.001.3a in room 001 -> - | -
422
+ PF0_1 | PS.base.a6 | WS.001.3b in room 001 -> - | -
423
+ PF0_1 | PS.base.b1 | WS.002.1a in room 002 -> Phone PH.hc002 (Hicom standard) | PS.base.ta5 -> Phone line -103
424
+ PF0_1 | PS.base.b2 | WS.002.1b in room 002 -> orion IF eth0 (PC) | Patchfield PF0_1 hub slot 1
425
+ PF0_1 | PS.base.b3 | WS.002.2a in room 002 -> Phone PH.hc003 (Hicom standard) | PS.base.tb2 -> Phone line -106
426
+ PF0_1 | PS.base.b4 | WS.002.2b in room 002 -> - | -
427
+ PF0_1 | PS.base.b5 | WS.002.3a in room 002 -> - | -
428
+ PF0_1 | PS.base.b6 | WS.002.3b in room 002 -> - | -
429
+ PF0_1 | PS.base.c1 | WS.003.1a in room 003 -> - | -
430
+ PF0_1 | PS.base.c2 | WS.003.1b in room 003 -> - | -
431
+ PF0_1 | PS.base.c3 | WS.003.2a in room 003 -> - | -
432
+ PF0_1 | PS.base.c4 | WS.003.2b in room 003 -> - | -
433
+ PF0_1 | PS.base.c5 | WS.003.3a in room 003 -> - | -
434
+ PF0_1 | PS.base.c6 | WS.003.3b in room 003 -> - | -
435
+ (18 rows)
436
+
437
+ select * from PField_v1 where pfname = 'PF0_2' order by slotname;
438
+ pfname | slotname | backside | patch
439
+ --------+-------------+--------------------------------+------------------------------------------------------------------------
440
+ PF0_2 | PS.base.ta1 | Phone line -0 (Central call) | PS.base.a1 -> WS.001.1a in room 001 -> Phone PH.hc001 (Hicom standard)
441
+ PF0_2 | PS.base.ta2 | Phone line -501 (Fax entrance) | PS.base.a3 -> WS.001.2a in room 001 -> Phone PH.fax001 (Canon fax)
442
+ PF0_2 | PS.base.ta3 | Phone line -102 | -
443
+ PF0_2 | PS.base.ta4 | - | -
444
+ PF0_2 | PS.base.ta5 | Phone line -103 | PS.base.b1 -> WS.002.1a in room 002 -> Phone PH.hc002 (Hicom standard)
445
+ PF0_2 | PS.base.ta6 | Phone line -104 | -
446
+ PF0_2 | PS.base.tb1 | - | -
447
+ PF0_2 | PS.base.tb2 | Phone line -106 | PS.base.b3 -> WS.002.2a in room 002 -> Phone PH.hc003 (Hicom standard)
448
+ PF0_2 | PS.base.tb3 | Phone line -108 | -
449
+ PF0_2 | PS.base.tb4 | Phone line -109 | -
450
+ PF0_2 | PS.base.tb5 | Phone line -121 | -
451
+ PF0_2 | PS.base.tb6 | Phone line -122 | -
452
+ (12 rows)
453
+
454
+ insert into PField values ('PF1_1', 'should fail due to unique index');
455
+ ERROR: Cannot insert a duplicate key into unique index pfield_name
456
+ update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
457
+ ERROR: WS.not.there does not exist in WSlot
458
+ update PSlot set backlink = 'XX.illegal' where slotname = 'PS.base.a1';
459
+ ERROR: illegal backlink beginning with XX
460
+ update PSlot set slotlink = 'PS.not.there' where slotname = 'PS.base.a1';
461
+ ERROR: undefined method `stlotlink_unset' for PLtemp:Module
462
+ update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
463
+ ERROR: undefined method `stlotlink_unset' for PLtemp:Module
464
+ insert into HSlot values ('HS', 'base.hub1', 1, '');
465
+ ERROR: Cannot insert a duplicate key into unique index hslot_name
466
+ insert into HSlot values ('HS', 'base.hub1', 20, '');
467
+ ERROR: no manual manipulation of HSlot
468
+ delete from HSlot;
469
+ ERROR: no manual manipulation of HSlot
470
+ insert into IFace values ('IF', 'notthere', 'eth0', '');
471
+ insert into IFace values ('IF', 'orion', 'ethernet_interface_name_too_long', '');
472
+ ERROR: IFace slotname IF.orion.ethernet_interface_name_too_long too long (20 char max)