Merge lp:~mumair/drizzle/drizzle-IPv6Address into lp:~drizzle-trunk/drizzle/development
- drizzle-IPv6Address
- Merge into development
Status: | Rejected |
---|---|
Rejected by: | Mark Atwood |
Proposed branch: | lp:~mumair/drizzle/drizzle-IPv6Address |
Merge into: | lp:~drizzle-trunk/drizzle/development |
Diff against target: |
2813 lines (+1597/-162) 52 files modified
drizzled/common.h (+3/-2) drizzled/create_field.cc (+4/-0) drizzled/display.cc (+3/-0) drizzled/error.cc (+3/-0) drizzled/error_t.h (+1/-0) drizzled/field.cc (+71/-1) drizzled/field.h (+1/-0) drizzled/field/ipv6.cc (+143/-0) drizzled/field/ipv6.h (+84/-0) drizzled/include.am (+3/-0) drizzled/item.cc (+2/-0) drizzled/item/type_holder.cc (+1/-0) drizzled/message.cc (+6/-0) drizzled/message/statement_transform.cc (+5/-0) drizzled/message/table.proto (+1/-0) drizzled/module/registry.cc (+116/-38) drizzled/module/registry.h (+47/-27) drizzled/parser.cc (+9/-0) drizzled/parser.h (+1/-0) drizzled/plugin/listen.cc (+37/-20) drizzled/sql_table.cc (+1/-0) drizzled/sql_yacc.yy (+14/-0) drizzled/symbol_hash.gperf (+1/-0) drizzled/table/instance/base.cc (+15/-0) drizzled/table_proto.cc (+1/-0) drizzled/type/ipv6.h (+470/-0) plugin/auth_file/auth_file.cc (+52/-29) plugin/innobase/handler/ha_innodb.cc (+2/-0) plugin/ipv6_function/ipv6_function.cc (+107/-0) plugin/ipv6_function/plugin.ini (+9/-0) plugin/logging_stats/scoreboard.cc (+91/-38) plugin/logging_stats/scoreboard.h (+6/-6) plugin/mysql_protocol/mysql_protocol.cc (+4/-0) tests/include.am (+1/-1) tests/suite/ipv6_type/r/alter_add_ipv6.result (+44/-0) tests/suite/ipv6_type/r/bad_conversions.result (+24/-0) tests/suite/ipv6_type/r/count.result (+19/-0) tests/suite/ipv6_type/r/create.result (+7/-0) tests/suite/ipv6_type/r/delete.result (+23/-0) tests/suite/ipv6_type/r/mixed.result (+17/-0) tests/suite/ipv6_type/r/order_by.result (+23/-0) tests/suite/ipv6_type/r/primary_key.result (+14/-0) tests/suite/ipv6_type/r/select_like_no_key.result (+18/-0) tests/suite/ipv6_type/t/alter_add_ipv6.test (+17/-0) tests/suite/ipv6_type/t/bad_conversions.test (+15/-0) tests/suite/ipv6_type/t/count.test (+10/-0) tests/suite/ipv6_type/t/create.test (+3/-0) tests/suite/ipv6_type/t/delete.test (+10/-0) tests/suite/ipv6_type/t/mixed.test (+11/-0) tests/suite/ipv6_type/t/order_by.test (+9/-0) tests/suite/ipv6_type/t/primary_key.test (+9/-0) tests/suite/ipv6_type/t/select_like_no_key.test (+9/-0) |
To merge this branch: | bzr merge lp:~mumair/drizzle/drizzle-IPv6Address |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stewart Smith (community) | Needs Fixing | ||
Olaf van der Spek (community) | Needs Fixing | ||
Mark Atwood | Pending | ||
Review via email: mp+70670@code.launchpad.net |
Commit message
Description of the change
Participate in Google Summer of Code 2011 for the Drizzle Project. Establish Native IPV6 Date Type for Drizzle. Branch can be tested from the test case suit name "ipv6_type".
Stewart Smith (stewart) wrote : | # |
A couple of general comments:
- style
- int foo()const; sholud have a space before 'const'
- (C) header should follow standard format, and then have one for
included code
- not sure about binary length versus string length, and some of the
names for constants aren't obvious as to what you're referring to.
On Sun, 07 Aug 2011 13:22:59 -0000, Muhammad Umair <email address hidden> wrote:
> --- drizzled/
> +++ drizzled/
> + int store(double ) { return 0; }
this doesn't look right to me
> + inline String *val_str(String *str) { return val_str(str, str); }
> + uint32_t size_of() const { return sizeof(*this); }
> +
> + static size_t max_string_length()
> + {
> + return type::IPv6::LENGTH;
> + }
> +};
> --- drizzled/
> +++ drizzled/
> @@ -51,55 +50,85 @@
>
> module:
> {
> + plugin:
> +
> /* Give all plugins a chance to cleanup, before
> * all plugins are deleted.
> * This can be used if shutdown code references
> * other plugins.
> */
> - BOOST_FOREACH(
> - it.second-
> + plugin_iter= plugin_
> + while (plugin_iter != plugin_
> + {
> + (*plugin_
> + ++plugin_iter;
> + }
Any reason why BOOST_FOREACH replaced?
Most of the rest of the changes around BOOST things I'm also
questionable about, especially so in a patch that sholud only add a
type.
There are a lot of needless changes here.
> + sprintf( destination ,
> "%03x:%
don't use sprintf, use safer function (such as snprintf)
> === modified file 'plugin/
> --- plugin/
> +++ plugin/
this all looks unneeded
> +class Generate: public drizzled:
> +{
> +public:
> + Generate(): drizzled:
> + void fix_length_
> + {
> +
> + max_length= (drizzled:
> + }
> + const char *func_name() const{ return "ipv6"; }
> + const char *fully_
> + drizzled::String *val_str(
> +};
function take any arguments? should have method fo rchecking argument count.
--
Stewart Smith
Unmerged revisions
- 2345. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 Branch with passed test cases
- 2344. By Muhammad Umair <umair@RemoteDesk>
-
With Passed Test Cases
- 2343. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 BRANCH
- 2342. By Muhammad Umair <umair@RemoteDesk>
-
Merged from trunk
- 2341. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 Branch Updated
- 2340. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 Branch
- 2339. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 Branch
- 2338. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 Branch
- 2337. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 Branch
- 2336. By Muhammad Umair <umair@RemoteDesk>
-
IPV6 Branch with test cases
Preview Diff
1 | === modified file 'drizzled/common.h' |
2 | --- drizzled/common.h 2011-05-21 00:29:07 +0000 |
3 | +++ drizzled/common.h 2011-08-07 13:22:33 +0000 |
4 | @@ -187,9 +187,10 @@ |
5 | DRIZZLE_TYPE_TIME, |
6 | DRIZZLE_TYPE_BOOLEAN, |
7 | DRIZZLE_TYPE_UUID, |
8 | - DRIZZLE_TYPE_MICROTIME |
9 | + DRIZZLE_TYPE_MICROTIME, |
10 | + DRIZZLE_TYPE_IPV6 |
11 | }; |
12 | -const int enum_field_types_size= DRIZZLE_TYPE_MICROTIME + 1; |
13 | +const int enum_field_types_size= DRIZZLE_TYPE_IPV6 + 1; |
14 | |
15 | } /* namespace drizzled */ |
16 | |
17 | |
18 | === modified file 'drizzled/create_field.cc' |
19 | --- drizzled/create_field.cc 2011-08-04 08:13:04 +0000 |
20 | +++ drizzled/create_field.cc 2011-08-07 13:22:33 +0000 |
21 | @@ -45,6 +45,7 @@ |
22 | #include <drizzled/field/datetime.h> |
23 | #include <drizzled/field/varstring.h> |
24 | #include <drizzled/field/uuid.h> |
25 | +#include <drizzled/field/ipv6.h> |
26 | #include <drizzled/temporal.h> |
27 | #include <drizzled/item/string.h> |
28 | #include <drizzled/table.h> |
29 | @@ -290,6 +291,9 @@ |
30 | case DRIZZLE_TYPE_UUID: |
31 | length= field::Uuid::max_string_length(); |
32 | break; |
33 | + case DRIZZLE_TYPE_IPV6: |
34 | + length= field::IPv6::max_string_length(); |
35 | + break; |
36 | case DRIZZLE_TYPE_BOOLEAN: |
37 | length= field::Boolean::max_string_length(); |
38 | break; |
39 | |
40 | === modified file 'drizzled/display.cc' |
41 | --- drizzled/display.cc 2011-05-21 00:29:07 +0000 |
42 | +++ drizzled/display.cc 2011-08-07 13:22:33 +0000 |
43 | @@ -56,6 +56,7 @@ |
44 | static const std::string DRIZZLE_TYPE_BLOB("DRIZZLE_TYPE_BLOB"); |
45 | static const std::string DRIZZLE_TYPE_UUID("DRIZZLE_TYPE_UUID"); |
46 | static const std::string DRIZZLE_TYPE_BOOLEAN("DRIZZLE_TYPE_BOOLEAN"); |
47 | +static const std::string DRIZZLE_TYPE_IPV6("DRIZZLE_TYPE_IPV6"); |
48 | |
49 | static const std::string FIELD_ITEM("FIELD_ITEM"); |
50 | static const std::string FUNC_ITEM("FUNC_ITEM"); |
51 | @@ -279,6 +280,8 @@ |
52 | return DRIZZLE_TYPE_UUID; |
53 | case drizzled::DRIZZLE_TYPE_BOOLEAN : |
54 | return DRIZZLE_TYPE_BOOLEAN; |
55 | + case drizzled::DRIZZLE_TYPE_IPV6 : |
56 | + return DRIZZLE_TYPE_IPV6; |
57 | } |
58 | |
59 | assert(0); |
60 | |
61 | === modified file 'drizzled/error.cc' |
62 | --- drizzled/error.cc 2011-03-24 00:03:05 +0000 |
63 | +++ drizzled/error.cc 2011-08-07 13:22:33 +0000 |
64 | @@ -597,6 +597,9 @@ |
65 | // For UUID type |
66 | ADD_ERROR_MESSAGE(ER_INVALID_UUID_VALUE, N_("Received an invalid UUID value")); |
67 | ADD_ERROR_MESSAGE(ER_INVALID_UUID_TIME, N_("The UUID was not created with a valid time")); |
68 | + |
69 | + // For IPV6 type |
70 | + ADD_ERROR_MESSAGE(ER_INVALID_IPV6_VALUE, N_("Received an invalid IPV6 value")); |
71 | |
72 | // For BOOL type |
73 | ADD_ERROR_MESSAGE(ER_INVALID_BOOLEAN_VALUE, N_("Received an invalid BOOLEAN value '%s'.")); |
74 | |
75 | === modified file 'drizzled/error_t.h' |
76 | --- drizzled/error_t.h 2011-03-14 05:40:28 +0000 |
77 | +++ drizzled/error_t.h 2011-08-07 13:22:33 +0000 |
78 | @@ -850,6 +850,7 @@ |
79 | ER_INVALID_CAST_TO_UNSIGNED, |
80 | ER_INVALID_UUID_TIME, |
81 | ER_INVALID_UUID_VALUE, |
82 | + ER_INVALID_IPV6_VALUE, |
83 | ER_SQL_KEYWORD, |
84 | ER_TABLE_DROP, |
85 | ER_TABLE_DROP_ERROR_OCCURRED, |
86 | |
87 | === modified file 'drizzled/field.cc' |
88 | --- drizzled/field.cc 2011-08-03 10:04:55 +0000 |
89 | +++ drizzled/field.cc 2011-08-07 13:22:33 +0000 |
90 | @@ -48,6 +48,7 @@ |
91 | #include <drizzled/field/microtime.h> |
92 | #include <drizzled/field/varstring.h> |
93 | #include <drizzled/field/uuid.h> |
94 | +#include <drizzled/field/ipv6.h> |
95 | #include <drizzled/time_functions.h> |
96 | #include <drizzled/internal/m_string.h> |
97 | #include <drizzled/table.h> |
98 | @@ -99,6 +100,8 @@ |
99 | DRIZZLE_TYPE_VARCHAR, |
100 | //DRIZZLE_TYPE_MICROTIME |
101 | DRIZZLE_TYPE_VARCHAR, |
102 | + //DRIZZLE_TYPE_IPV6 |
103 | + DRIZZLE_TYPE_VARCHAR, |
104 | }, |
105 | /* DRIZZLE_TYPE_DOUBLE -> */ |
106 | { |
107 | @@ -132,6 +135,8 @@ |
108 | DRIZZLE_TYPE_VARCHAR, |
109 | //DRIZZLE_TYPE_MICROTIME |
110 | DRIZZLE_TYPE_VARCHAR, |
111 | + //DRIZZLE_TYPE_IPV6 |
112 | + DRIZZLE_TYPE_VARCHAR, |
113 | }, |
114 | /* DRIZZLE_TYPE_NULL -> */ |
115 | { |
116 | @@ -165,6 +170,8 @@ |
117 | DRIZZLE_TYPE_UUID, |
118 | //DRIZZLE_TYPE_MICROTIME |
119 | DRIZZLE_TYPE_MICROTIME, |
120 | + //DRIZZLE_TYPE_IPV6 |
121 | + DRIZZLE_TYPE_VARCHAR, |
122 | }, |
123 | /* DRIZZLE_TYPE_TIMESTAMP -> */ |
124 | { |
125 | @@ -198,6 +205,8 @@ |
126 | DRIZZLE_TYPE_VARCHAR, |
127 | //DRIZZLE_TYPE_MICROTIME |
128 | DRIZZLE_TYPE_VARCHAR, |
129 | + //DRIZZLE_TYPE_IPV6 |
130 | + DRIZZLE_TYPE_VARCHAR, |
131 | }, |
132 | /* DRIZZLE_TYPE_LONGLONG -> */ |
133 | { |
134 | @@ -230,6 +239,8 @@ |
135 | DRIZZLE_TYPE_VARCHAR, |
136 | //DRIZZLE_TYPE_MICROTIME |
137 | DRIZZLE_TYPE_VARCHAR, |
138 | + //DRIZZLE_TYPE_IPV6 |
139 | + DRIZZLE_TYPE_VARCHAR, |
140 | }, |
141 | /* DRIZZLE_TYPE_DATETIME -> */ |
142 | { |
143 | @@ -263,6 +274,8 @@ |
144 | DRIZZLE_TYPE_VARCHAR, |
145 | //DRIZZLE_TYPE_MICROTIME |
146 | DRIZZLE_TYPE_VARCHAR, |
147 | + //DRIZZLE_TYPE_IPV6 |
148 | + DRIZZLE_TYPE_VARCHAR, |
149 | }, |
150 | /* DRIZZLE_TYPE_DATE -> */ |
151 | { |
152 | @@ -296,6 +309,8 @@ |
153 | DRIZZLE_TYPE_VARCHAR, |
154 | //DRIZZLE_TYPE_MICROTIME |
155 | DRIZZLE_TYPE_VARCHAR, |
156 | + //DRIZZLE_TYPE_IPV6 |
157 | + DRIZZLE_TYPE_VARCHAR, |
158 | }, |
159 | /* DRIZZLE_TYPE_VARCHAR -> */ |
160 | { |
161 | @@ -329,6 +344,8 @@ |
162 | DRIZZLE_TYPE_VARCHAR, |
163 | //DRIZZLE_TYPE_MICROTIME |
164 | DRIZZLE_TYPE_VARCHAR, |
165 | + //DRIZZLE_TYPE_IPV6 |
166 | + DRIZZLE_TYPE_VARCHAR, |
167 | }, |
168 | /* DRIZZLE_TYPE_DECIMAL -> */ |
169 | { |
170 | @@ -362,6 +379,8 @@ |
171 | DRIZZLE_TYPE_VARCHAR, |
172 | //DRIZZLE_TYPE_MICROTIME |
173 | DRIZZLE_TYPE_VARCHAR, |
174 | + //DRIZZLE_TYPE_IPV6 |
175 | + DRIZZLE_TYPE_VARCHAR, |
176 | }, |
177 | /* DRIZZLE_TYPE_ENUM -> */ |
178 | { |
179 | @@ -395,6 +414,8 @@ |
180 | DRIZZLE_TYPE_VARCHAR, |
181 | //DRIZZLE_TYPE_MICROTIME |
182 | DRIZZLE_TYPE_VARCHAR, |
183 | + //DRIZZLE_TYPE_IPV6 |
184 | + DRIZZLE_TYPE_VARCHAR, |
185 | }, |
186 | /* DRIZZLE_TYPE_BLOB -> */ |
187 | { |
188 | @@ -428,6 +449,8 @@ |
189 | DRIZZLE_TYPE_VARCHAR, |
190 | //DRIZZLE_TYPE_MICROTIME |
191 | DRIZZLE_TYPE_VARCHAR, |
192 | + //DRIZZLE_TYPE_IPV6 |
193 | + DRIZZLE_TYPE_VARCHAR, |
194 | }, |
195 | /* DRIZZLE_TYPE_TIME -> */ |
196 | { |
197 | @@ -461,6 +484,8 @@ |
198 | DRIZZLE_TYPE_UUID, |
199 | //DRIZZLE_TYPE_MICROTIME |
200 | DRIZZLE_TYPE_VARCHAR, |
201 | + //DRIZZLE_TYPE_IPV6 |
202 | + DRIZZLE_TYPE_VARCHAR, |
203 | }, |
204 | /* DRIZZLE_TYPE_BOOLEAN -> */ |
205 | { |
206 | @@ -494,6 +519,8 @@ |
207 | DRIZZLE_TYPE_VARCHAR, |
208 | //DRIZZLE_TYPE_MICROTIME |
209 | DRIZZLE_TYPE_VARCHAR, |
210 | + //DRIZZLE_TYPE_IPV6 |
211 | + DRIZZLE_TYPE_VARCHAR, |
212 | }, |
213 | /* DRIZZLE_TYPE_UUID -> */ |
214 | { |
215 | @@ -527,6 +554,8 @@ |
216 | DRIZZLE_TYPE_UUID, |
217 | //DRIZZLE_TYPE_MICROTIME |
218 | DRIZZLE_TYPE_VARCHAR, |
219 | + //DRIZZLE_TYPE_IPV6 |
220 | + DRIZZLE_TYPE_VARCHAR, |
221 | }, |
222 | /* DRIZZLE_TYPE_MICROTIME -> */ |
223 | { |
224 | @@ -560,7 +589,45 @@ |
225 | DRIZZLE_TYPE_UUID, |
226 | //DRIZZLE_TYPE_MICROTIME |
227 | DRIZZLE_TYPE_MICROTIME, |
228 | - }, |
229 | + //DRIZZLE_TYPE_IPV6 |
230 | + DRIZZLE_TYPE_VARCHAR, |
231 | + }, |
232 | + /* DRIZZLE_TYPE_IPV6 -> */ |
233 | + { |
234 | + //DRIZZLE_TYPE_LONG |
235 | + DRIZZLE_TYPE_VARCHAR, |
236 | + //DRIZZLE_TYPE_DOUBLE |
237 | + DRIZZLE_TYPE_VARCHAR, |
238 | + //DRIZZLE_TYPE_NULL |
239 | + DRIZZLE_TYPE_IPV6, |
240 | + //DRIZZLE_TYPE_TIMESTAMP |
241 | + DRIZZLE_TYPE_VARCHAR, |
242 | + //DRIZZLE_TYPE_LONGLONG |
243 | + DRIZZLE_TYPE_VARCHAR, |
244 | + //DRIZZLE_TYPE_DATETIME |
245 | + DRIZZLE_TYPE_VARCHAR, |
246 | + //DRIZZLE_TYPE_DATE |
247 | + DRIZZLE_TYPE_VARCHAR, |
248 | + //DRIZZLE_TYPE_VARCHAR |
249 | + DRIZZLE_TYPE_VARCHAR, |
250 | + //DRIZZLE_TYPE_DECIMAL |
251 | + DRIZZLE_TYPE_VARCHAR, |
252 | + //DRIZZLE_TYPE_VARCHAR, |
253 | + DRIZZLE_TYPE_VARCHAR, |
254 | + //DRIZZLE_TYPE_BLOB |
255 | + DRIZZLE_TYPE_BLOB, |
256 | + //DRIZZLE_TYPE_TIME |
257 | + DRIZZLE_TYPE_TIME, |
258 | + //DRIZZLE_TYPE_BOOLEAN |
259 | + DRIZZLE_TYPE_VARCHAR, |
260 | + //DRIZZLE_TYPE_UUID |
261 | + DRIZZLE_TYPE_UUID, |
262 | + //DRIZZLE_TYPE_MICROTIME |
263 | + DRIZZLE_TYPE_MICROTIME, |
264 | + //DRIZZLE_TYPE_IPV6 |
265 | + DRIZZLE_TYPE_VARCHAR, |
266 | + }, |
267 | + |
268 | }; |
269 | |
270 | static Item_result field_types_result_type [enum_field_types_size]= |
271 | @@ -595,6 +662,8 @@ |
272 | STRING_RESULT, |
273 | //DRIZZLE_TYPE_MICROTIME |
274 | STRING_RESULT, |
275 | + //DRIZZLE_TYPE_IPV6 |
276 | + STRING_RESULT, |
277 | }; |
278 | |
279 | bool test_if_important_data(const charset_info_st * const cs, |
280 | @@ -1111,6 +1180,7 @@ |
281 | case DRIZZLE_TYPE_MICROTIME: return field::Microtime::max_string_length(); |
282 | case DRIZZLE_TYPE_TIMESTAMP: return field::Epoch::max_string_length(); |
283 | case DRIZZLE_TYPE_BOOLEAN: return field::Boolean::max_string_length(); |
284 | + case DRIZZLE_TYPE_IPV6: return field::IPv6::max_string_length(); |
285 | case DRIZZLE_TYPE_DATE: |
286 | case DRIZZLE_TYPE_ENUM: |
287 | case DRIZZLE_TYPE_LONG: return 4; |
288 | |
289 | === modified file 'drizzled/field.h' |
290 | --- drizzled/field.h 2011-08-03 10:04:55 +0000 |
291 | +++ drizzled/field.h 2011-08-07 13:22:33 +0000 |
292 | @@ -762,6 +762,7 @@ |
293 | case DRIZZLE_TYPE_LONGLONG: |
294 | case DRIZZLE_TYPE_NULL: |
295 | case DRIZZLE_TYPE_UUID: |
296 | + case DRIZZLE_TYPE_IPV6: |
297 | case DRIZZLE_TYPE_VARCHAR: |
298 | return false; |
299 | } |
300 | |
301 | === added file 'drizzled/field/ipv6.cc' |
302 | --- drizzled/field/ipv6.cc 1970-01-01 00:00:00 +0000 |
303 | +++ drizzled/field/ipv6.cc 2011-08-07 13:22:33 +0000 |
304 | @@ -0,0 +1,143 @@ |
305 | +/* |
306 | + Original copyright header listed below. This comes via rsync. |
307 | + Any additional changes are provided via the same license as the original. |
308 | + |
309 | + Copyright (C) 2011 Muhammad Umair |
310 | + |
311 | +*/ |
312 | +/* |
313 | + * Copyright (C) 1996-2001 Internet Software Consortium. |
314 | + * |
315 | + * Permission to use, copy, modify, and distribute this software for any |
316 | + * purpose with or without fee is hereby granted, provided that the above |
317 | + * copyright notice and this permission notice appear in all copies. |
318 | + * |
319 | + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM |
320 | + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL |
321 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL |
322 | + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, |
323 | + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
324 | + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
325 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
326 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
327 | + */ |
328 | + |
329 | +#include "config.h" |
330 | + |
331 | +#include <algorithm> |
332 | + |
333 | + |
334 | + |
335 | +#include <drizzled/field/ipv6.h> |
336 | + |
337 | +#include <drizzled/error.h> |
338 | +#include <drizzled/internal/my_sys.h> |
339 | +#include <drizzled/session.h> |
340 | +#include <drizzled/table.h> |
341 | + |
342 | + |
343 | +namespace drizzled |
344 | +{ |
345 | +namespace field |
346 | +{ |
347 | + |
348 | +IPv6::IPv6(unsigned char *ptr_arg, |
349 | + uint32_t len_arg, |
350 | + unsigned char *null_ptr_arg, |
351 | + unsigned char null_bit_arg, |
352 | + const char *field_name_arg) : |
353 | + Field(ptr_arg, len_arg, |
354 | + null_ptr_arg, |
355 | + null_bit_arg, |
356 | + Field::NONE, |
357 | + field_name_arg) |
358 | +{ |
359 | +} |
360 | + |
361 | +int IPv6::cmp(const unsigned char *a, const unsigned char *b) |
362 | +{ |
363 | + return memcmp(a, b, max_string_length()); |
364 | +} |
365 | + |
366 | + |
367 | +int IPv6::store(const char *from, uint32_t, const charset_info_st * const ) |
368 | +{ |
369 | + ASSERT_COLUMN_MARKED_FOR_WRITE; |
370 | + type::IPv6 ptr_address; |
371 | + |
372 | + |
373 | + if (not ptr_address.inet_pton(from)) |
374 | + { |
375 | + my_error(ER_INVALID_IPV6_VALUE, MYF(ME_FATALERROR)); |
376 | + return 1; |
377 | + } |
378 | + |
379 | + ptr_address.store_object(ptr); |
380 | + |
381 | + return 0; |
382 | +} |
383 | + |
384 | +int IPv6::store(int64_t , bool ) |
385 | +{ |
386 | + ASSERT_COLUMN_MARKED_FOR_WRITE; |
387 | + my_error(ER_INVALID_IPV6_VALUE, MYF(ME_FATALERROR)); |
388 | + return 1; |
389 | +} |
390 | + |
391 | +int IPv6::store_decimal(const drizzled::type::Decimal*) |
392 | +{ |
393 | + ASSERT_COLUMN_MARKED_FOR_WRITE; |
394 | + my_error(ER_INVALID_IPV6_VALUE, MYF(ME_FATALERROR)); |
395 | + return 1; |
396 | +} |
397 | + |
398 | +void IPv6::sql_type(String &res) const |
399 | +{ |
400 | + res.set_ascii(STRING_WITH_LEN("ipv6")); |
401 | +} |
402 | + |
403 | +double IPv6::val_real()const |
404 | +{ |
405 | + ASSERT_COLUMN_MARKED_FOR_READ; |
406 | + my_error(ER_INVALID_IPV6_VALUE, MYF(ME_FATALERROR)); |
407 | + return 0; |
408 | +} |
409 | + |
410 | +int64_t IPv6::val_int()const |
411 | +{ |
412 | + ASSERT_COLUMN_MARKED_FOR_READ; |
413 | + my_error(ER_INVALID_IPV6_VALUE, MYF(ME_FATALERROR)); |
414 | + return 0; |
415 | +} |
416 | + |
417 | +String *IPv6::val_str(String *val_buffer, String *)const |
418 | +{ |
419 | + |
420 | + const charset_info_st * const cs= &my_charset_bin; |
421 | + uint32_t mlength= (type::IPv6::IPV6_BUFFER_LENGTH) * cs->mbmaxlen; |
422 | + type::IPv6 ptr_address; |
423 | + |
424 | + val_buffer->alloc(mlength); |
425 | + char *buffer=(char*) val_buffer->ptr(); |
426 | + |
427 | + |
428 | + ASSERT_COLUMN_MARKED_FOR_READ; |
429 | + |
430 | + ptr_address.restore_object(ptr); |
431 | + ptr_address.inet_ntop(buffer); |
432 | + |
433 | + val_buffer->length(type::IPv6::IPV6_DISPLAY_LENGTH); |
434 | + |
435 | + return val_buffer; |
436 | + |
437 | +} |
438 | + |
439 | +void IPv6::sort_string(unsigned char *to, uint32_t length_arg) |
440 | +{ |
441 | + assert(length_arg == type::IPv6::LENGTH); |
442 | + memcpy(to, ptr, length_arg); |
443 | +} |
444 | + |
445 | + |
446 | +} /* namespace field */ |
447 | +} /* namespace drizzled */ |
448 | |
449 | === added file 'drizzled/field/ipv6.h' |
450 | --- drizzled/field/ipv6.h 1970-01-01 00:00:00 +0000 |
451 | +++ drizzled/field/ipv6.h 2011-08-07 13:22:33 +0000 |
452 | @@ -0,0 +1,84 @@ |
453 | +/* |
454 | + Original copyright header listed below. This comes via rsync. |
455 | + Any additional changes are provided via the same license as the original. |
456 | + |
457 | + Copyright (C) 2011 Muhammad Umair |
458 | + |
459 | +*/ |
460 | +/* |
461 | + * Copyright (C) 1996-2001 Internet Software Consortium. |
462 | + * |
463 | + * Permission to use, copy, modify, and distribute this software for any |
464 | + * purpose with or without fee is hereby granted, provided that the above |
465 | + * copyright notice and this permission notice appear in all copies. |
466 | + * |
467 | + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM |
468 | + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL |
469 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL |
470 | + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, |
471 | + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
472 | + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
473 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
474 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
475 | + */ |
476 | + |
477 | + |
478 | +#ifndef DRIZZLED_FIELD_IPV6_H_INCLUDED |
479 | +#define DRIZZLED_FIELD_IPV6_H_INCLUDED |
480 | + |
481 | + |
482 | +#include <drizzled/field.h> |
483 | +#include <string> |
484 | +#include <drizzled/type/ipv6.h> |
485 | + |
486 | + |
487 | +namespace drizzled |
488 | +{ |
489 | +namespace field |
490 | +{ |
491 | + |
492 | +class IPv6:public Field { |
493 | +// const CHARSET_INFO *field_charset; |
494 | + const charset_info_st *field_charset; |
495 | + |
496 | +public: |
497 | + IPv6(unsigned char *ptr_arg, |
498 | + uint32_t len_arg, |
499 | + unsigned char *null_ptr_arg, |
500 | + unsigned char null_bit_arg, |
501 | + const char *field_name_arg); |
502 | + |
503 | + enum_field_types type() const { return DRIZZLE_TYPE_IPV6; } |
504 | + enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } |
505 | + bool zero_pack() const { return 0; } |
506 | + int reset(void) { memset(ptr, 0, type::IPv6::LENGTH); return 0; } |
507 | + uint32_t pack_length() const { return type::IPv6::LENGTH; } |
508 | + uint32_t key_length() const { return type::IPv6::LENGTH; } |
509 | + |
510 | + int store(const char *to,uint32_t length, const charset_info_st * const charset); |
511 | + int store(int64_t nr, bool unsigned_val); |
512 | + double val_real()const; |
513 | + int64_t val_int()const; |
514 | + String *val_str(String*,String *)const; |
515 | + void sql_type(drizzled::String&) const; |
516 | + int store_decimal(const drizzled::type::Decimal*); |
517 | + |
518 | + Item_result result_type () const { return STRING_RESULT; } |
519 | + int cmp(const unsigned char*, const unsigned char*); |
520 | + void sort_string(unsigned char*, uint32_t); |
521 | + uint32_t max_display_length() { return type::IPv6::IPV6_DISPLAY_LENGTH; } |
522 | + |
523 | + int store(double ) { return 0; } |
524 | + inline String *val_str(String *str) { return val_str(str, str); } |
525 | + uint32_t size_of() const { return sizeof(*this); } |
526 | + |
527 | + static size_t max_string_length() |
528 | + { |
529 | + return type::IPv6::LENGTH; |
530 | + } |
531 | +}; |
532 | + |
533 | +} /* namespace field */ |
534 | +} /* namespace drizzled */ |
535 | + |
536 | +#endif // DRIZZLED_FIELD_IPV6_H_INCLUDED |
537 | |
538 | === modified file 'drizzled/include.am' |
539 | --- drizzled/include.am 2011-08-04 08:13:04 +0000 |
540 | +++ drizzled/include.am 2011-08-07 13:22:33 +0000 |
541 | @@ -111,6 +111,7 @@ |
542 | drizzled/field/str.h \ |
543 | drizzled/field/time.h \ |
544 | drizzled/field/uuid.h \ |
545 | + drizzled/field/ipv6.h \ |
546 | drizzled/field/varstring.h \ |
547 | drizzled/field_iterator.h \ |
548 | drizzled/file_exchange.h \ |
549 | @@ -506,6 +507,7 @@ |
550 | drizzled/type/decimal.h \ |
551 | drizzled/type/time.h \ |
552 | drizzled/type/uuid.h \ |
553 | + drizzled/type/ipv6.h \ |
554 | drizzled/typelib.h \ |
555 | drizzled/unique.h \ |
556 | drizzled/unireg.h \ |
557 | @@ -586,6 +588,7 @@ |
558 | drizzled/field/str.cc \ |
559 | drizzled/field/time.cc \ |
560 | drizzled/field/uuid.cc \ |
561 | + drizzled/field/ipv6.cc \ |
562 | drizzled/field/varstring.cc \ |
563 | drizzled/field_conv.cc \ |
564 | drizzled/field_iterator.cc \ |
565 | |
566 | === modified file 'drizzled/item.cc' |
567 | --- drizzled/item.cc 2011-07-07 13:57:49 +0000 |
568 | +++ drizzled/item.cc 2011-08-07 13:22:33 +0000 |
569 | @@ -1182,6 +1182,7 @@ |
570 | break; |
571 | case DRIZZLE_TYPE_BOOLEAN: |
572 | case DRIZZLE_TYPE_UUID: |
573 | + case DRIZZLE_TYPE_IPV6: |
574 | case DRIZZLE_TYPE_ENUM: |
575 | case DRIZZLE_TYPE_VARCHAR: |
576 | return make_string_field(table); |
577 | @@ -1330,6 +1331,7 @@ |
578 | case DRIZZLE_TYPE_VARCHAR: |
579 | case DRIZZLE_TYPE_BOOLEAN: |
580 | case DRIZZLE_TYPE_UUID: |
581 | + case DRIZZLE_TYPE_IPV6: |
582 | case DRIZZLE_TYPE_DECIMAL: |
583 | { |
584 | if (String* res=val_str(buffer)) |
585 | |
586 | === modified file 'drizzled/item/type_holder.cc' |
587 | --- drizzled/item/type_holder.cc 2011-06-22 20:05:58 +0000 |
588 | +++ drizzled/item/type_holder.cc 2011-08-07 13:22:33 +0000 |
589 | @@ -209,6 +209,7 @@ |
590 | case DRIZZLE_TYPE_TIME: |
591 | case DRIZZLE_TYPE_BOOLEAN: |
592 | case DRIZZLE_TYPE_UUID: |
593 | + case DRIZZLE_TYPE_IPV6: |
594 | case DRIZZLE_TYPE_MICROTIME: |
595 | case DRIZZLE_TYPE_TIMESTAMP: |
596 | case DRIZZLE_TYPE_DATETIME: |
597 | |
598 | === modified file 'drizzled/message.cc' |
599 | --- drizzled/message.cc 2011-07-14 22:12:02 +0000 |
600 | +++ drizzled/message.cc 2011-08-07 13:22:33 +0000 |
601 | @@ -51,6 +51,7 @@ |
602 | static const std::string TIME("TIME"); |
603 | static const std::string UUID("UUID"); |
604 | static const std::string BOOLEAN("BOOLEAN"); |
605 | +static const std::string IPV6("IPV6"); |
606 | |
607 | static const std::string UNDEFINED("UNDEFINED"); |
608 | static const std::string RESTRICT("RESTRICT"); |
609 | @@ -109,6 +110,7 @@ |
610 | case message::Table::Field::TIME: |
611 | case message::Table::Field::UUID: |
612 | case message::Table::Field::BOOLEAN: |
613 | + case message::Table::Field::IPV6: |
614 | break; |
615 | } |
616 | |
617 | @@ -147,6 +149,8 @@ |
618 | return UUID; |
619 | case message::Table::Field::BOOLEAN: |
620 | return BOOLEAN; |
621 | + case message::Table::Field::IPV6: |
622 | + return IPV6; |
623 | } |
624 | |
625 | abort(); |
626 | @@ -182,6 +186,8 @@ |
627 | return UUID; |
628 | case message::Table::Field::BOOLEAN: |
629 | return BOOLEAN; |
630 | + case message::Table::Field::IPV6: |
631 | + return IPV6; |
632 | } |
633 | |
634 | abort(); |
635 | |
636 | === modified file 'drizzled/message/statement_transform.cc' |
637 | --- drizzled/message/statement_transform.cc 2011-04-28 18:07:05 +0000 |
638 | +++ drizzled/message/statement_transform.cc 2011-08-07 13:22:33 +0000 |
639 | @@ -1425,6 +1425,9 @@ |
640 | case Table::Field::UUID: |
641 | destination.append(" UUID"); |
642 | break; |
643 | + case Table::Field::IPV6: |
644 | + destination.append(" IPV6"); |
645 | + break; |
646 | case Table::Field::BOOLEAN: |
647 | destination.append(" BOOLEAN"); |
648 | break; |
649 | @@ -1606,6 +1609,8 @@ |
650 | return Table::Field::UUID; |
651 | case DRIZZLE_TYPE_BOOLEAN: |
652 | return Table::Field::BOOLEAN; |
653 | + case DRIZZLE_TYPE_IPV6: |
654 | + return Table::Field::IPV6; |
655 | } |
656 | |
657 | assert(false); |
658 | |
659 | === modified file 'drizzled/message/table.proto' |
660 | --- drizzled/message/table.proto 2011-04-04 21:37:55 +0000 |
661 | +++ drizzled/message/table.proto 2011-08-07 13:22:33 +0000 |
662 | @@ -82,6 +82,7 @@ |
663 | UUID = 11; |
664 | TIME = 12; |
665 | BOOLEAN = 13; |
666 | + IPV6 = 14; |
667 | } |
668 | |
669 | message FieldOptions { |
670 | |
671 | === modified file 'drizzled/module/registry.cc' |
672 | --- drizzled/module/registry.cc 2011-06-23 11:44:30 +0000 |
673 | +++ drizzled/module/registry.cc 2011-08-07 13:22:33 +0000 |
674 | @@ -32,14 +32,13 @@ |
675 | #include <drizzled/show.h> |
676 | #include <drizzled/cursor.h> |
677 | #include <drizzled/abort_exception.h> |
678 | -#include <drizzled/util/find_ptr.h> |
679 | |
680 | #include <boost/bind.hpp> |
681 | -#include <boost/foreach.hpp> |
682 | |
683 | using namespace std; |
684 | |
685 | -namespace drizzled { |
686 | +namespace drizzled |
687 | +{ |
688 | |
689 | module::Registry::Registry() : |
690 | module_registry_(), |
691 | @@ -51,55 +50,85 @@ |
692 | |
693 | module::Registry::~Registry() |
694 | { |
695 | + plugin::Plugin::map::iterator plugin_iter; |
696 | + |
697 | /* Give all plugins a chance to cleanup, before |
698 | * all plugins are deleted. |
699 | * This can be used if shutdown code references |
700 | * other plugins. |
701 | */ |
702 | - BOOST_FOREACH(plugin::Plugin::map::reference it, plugin_registry) |
703 | - it.second->shutdownPlugin(); |
704 | + plugin_iter= plugin_registry.begin(); |
705 | + while (plugin_iter != plugin_registry.end()) |
706 | + { |
707 | + (*plugin_iter).second->shutdownPlugin(); |
708 | + ++plugin_iter; |
709 | + } |
710 | |
711 | plugin::Plugin::vector error_plugins; |
712 | - BOOST_FOREACH(plugin::Plugin::map::reference it, plugin_registry) |
713 | + plugin_iter= plugin_registry.begin(); |
714 | + while (plugin_iter != plugin_registry.end()) |
715 | { |
716 | - if (it.second->removeLast()) |
717 | - error_plugins.push_back(it.second); |
718 | + if ((*plugin_iter).second->removeLast()) |
719 | + { |
720 | + error_plugins.push_back((*plugin_iter).second); |
721 | + } |
722 | else |
723 | - delete it.second; |
724 | + { |
725 | + delete (*plugin_iter).second; |
726 | + } |
727 | + ++plugin_iter; |
728 | } |
729 | |
730 | - BOOST_FOREACH(plugin::Plugin::vector::reference it, error_plugins) |
731 | - delete it; |
732 | + for (plugin::Plugin::vector::iterator iter= error_plugins.begin(); |
733 | + iter != error_plugins.end(); iter++) |
734 | + { |
735 | + delete *iter; |
736 | + } |
737 | |
738 | plugin_registry.clear(); |
739 | |
740 | #if 0 |
741 | - /* |
742 | @TODO When we delete modules here, we segfault on a bad string. Why? |
743 | - */ |
744 | + ModuleMap::iterator module_iter= module_registry_.begin(); |
745 | |
746 | - BOOST_FOREACH(ModuleMap::reference it, module_registry_) |
747 | - delete it.second; |
748 | + while (module_iter != module_registry_.end()) |
749 | + { |
750 | + delete (*module_iter).second; |
751 | + ++module_iter; |
752 | + } |
753 | module_registry_.clear(); |
754 | #endif |
755 | - BOOST_FOREACH(LibraryMap::reference it, library_registry_) |
756 | - delete it.second; |
757 | + LibraryMap::iterator library_iter= library_registry_.begin(); |
758 | + while (library_iter != library_registry_.end()) |
759 | + { |
760 | + delete (*library_iter).second; |
761 | + ++library_iter; |
762 | + } |
763 | library_registry_.clear(); |
764 | } |
765 | |
766 | void module::Registry::shutdown() |
767 | { |
768 | - delete &singleton(); |
769 | + module::Registry& registry= singleton(); |
770 | + delete ®istry; |
771 | } |
772 | |
773 | -module::Module* module::Registry::find(const std::string& name) |
774 | +module::Module *module::Registry::find(std::string name) |
775 | { |
776 | - return find_ptr2(module_registry_, boost::to_lower_copy(name)); |
777 | + std::transform(name.begin(), name.end(), name.begin(), ::tolower); |
778 | + |
779 | + ModuleMap::iterator map_iter; |
780 | + map_iter= module_registry_.find(name); |
781 | + if (map_iter != module_registry_.end()) |
782 | + return (*map_iter).second; |
783 | + return NULL; |
784 | } |
785 | |
786 | void module::Registry::add(module::Module *handle) |
787 | { |
788 | - std::string add_str(boost::to_lower_copy(handle->getName())); |
789 | + std::string add_str(handle->getName()); |
790 | + transform(add_str.begin(), add_str.end(), |
791 | + add_str.begin(), ::tolower); |
792 | |
793 | module_registry_[add_str]= handle; |
794 | |
795 | @@ -108,23 +137,45 @@ |
796 | depend_graph_->properties(handle_vertex)= vertex_info; |
797 | |
798 | handle->setVertexHandle(new VertexHandle(handle_vertex)); |
799 | + |
800 | } |
801 | |
802 | void module::Registry::remove(module::Module *handle) |
803 | { |
804 | - module_registry_.erase(boost::to_lower_copy(handle->getName())); |
805 | + std::string remove_str(handle->getName()); |
806 | + std::transform(remove_str.begin(), remove_str.end(), |
807 | + remove_str.begin(), ::tolower); |
808 | + |
809 | + module_registry_.erase(remove_str); |
810 | +} |
811 | + |
812 | +void module::Registry::copy(plugin::Plugin::vector &arg) |
813 | +{ |
814 | + arg.reserve(plugin_registry.size()); |
815 | + |
816 | + std::transform(plugin_registry.begin(), |
817 | + plugin_registry.end(), |
818 | + std::back_inserter(arg), |
819 | + boost::bind(&plugin::Plugin::map::value_type::second, _1) ); |
820 | + assert(arg.size() == plugin_registry.size()); |
821 | } |
822 | |
823 | void module::Registry::buildDeps() |
824 | { |
825 | - BOOST_FOREACH(ModuleMap::reference map_iter, module_registry_) |
826 | + ModuleMap::iterator map_iter= module_registry_.begin(); |
827 | + while (map_iter != module_registry_.end()) |
828 | { |
829 | - Module* handle= map_iter.second; |
830 | - BOOST_FOREACH(Module::Depends::const_reference handle_deps, handle->getDepends()) |
831 | + Module *handle= (*map_iter).second; |
832 | + Module::Depends::const_iterator handle_deps= handle->getDepends().begin(); |
833 | + while (handle_deps != handle->getDepends().end()) |
834 | { |
835 | - std::string dep_str(boost::to_lower_copy(handle_deps)); |
836 | + std::string dep_str((*handle_deps)); |
837 | + transform(dep_str.begin(), dep_str.end(), |
838 | + dep_str.begin(), ::tolower); |
839 | + |
840 | bool found_dep= false; |
841 | - for (vertex_iter it= boost::vertices(depend_graph_->getGraph()).first; it != vertices(depend_graph_->getGraph()).second; it++) |
842 | + vertex_iter it= boost::vertices(depend_graph_->getGraph()).first; |
843 | + while (it != vertices(depend_graph_->getGraph()).second) |
844 | { |
845 | if (depend_graph_->properties(*it).getName() == dep_str) |
846 | { |
847 | @@ -132,14 +183,21 @@ |
848 | add_edge(handle->getVertexHandle()->getVertexDesc(), *it, depend_graph_->getGraph()); |
849 | break; |
850 | } |
851 | + ++it; |
852 | } |
853 | if (not found_dep) |
854 | { |
855 | - errmsg_printf(error::ERROR, _("Couldn't process plugin module dependencies. %s depends on %s but %s is not to be loaded.\n"), |
856 | - handle->getName().c_str(), dep_str.c_str(), dep_str.c_str()); |
857 | + errmsg_printf(error::ERROR, |
858 | + _("Couldn't process plugin module dependencies. " |
859 | + "%s depends on %s but %s is not to be loaded.\n"), |
860 | + handle->getName().c_str(), |
861 | + dep_str.c_str(), dep_str.c_str()); |
862 | DRIZZLE_ABORT; |
863 | } |
864 | + |
865 | + ++handle_deps; |
866 | } |
867 | + ++map_iter; |
868 | } |
869 | deps_built_= true; |
870 | } |
871 | @@ -147,47 +205,67 @@ |
872 | module::Registry::ModuleList module::Registry::getList() |
873 | { |
874 | if (not deps_built_) |
875 | + { |
876 | buildDeps(); |
877 | + } |
878 | + |
879 | + std::vector<module::Module *> plugins; |
880 | + |
881 | VertexList vertex_list; |
882 | + |
883 | boost::topological_sort(depend_graph_->getGraph(), std::back_inserter(vertex_list)); |
884 | - ModuleList plugins; |
885 | - BOOST_FOREACH(VertexList::reference it, vertex_list) |
886 | + |
887 | + for (VertexList::iterator i = vertex_list.begin(); |
888 | + i != vertex_list.end(); ++i) |
889 | { |
890 | - if (Module* mod_ptr= depend_graph_->properties(it).getModule()) |
891 | + Module *mod_ptr= depend_graph_->properties(*i).getModule(); |
892 | + if (mod_ptr != NULL) |
893 | + { |
894 | plugins.push_back(mod_ptr); |
895 | + } |
896 | } |
897 | + |
898 | return plugins; |
899 | } |
900 | |
901 | -module::Library *module::Registry::addLibrary(const std::string &plugin_name, bool builtin) |
902 | +module::Library *module::Registry::addLibrary(const std::string &plugin_name, |
903 | + bool builtin) |
904 | { |
905 | + |
906 | /* If this dll is already loaded just return it */ |
907 | module::Library *library= findLibrary(plugin_name); |
908 | - if (library) |
909 | + if (library != NULL) |
910 | + { |
911 | return library; |
912 | + } |
913 | |
914 | library= module::Library::loadLibrary(plugin_name, builtin); |
915 | - if (library) |
916 | + if (library != NULL) |
917 | { |
918 | /* Add this dll to the map */ |
919 | library_registry_.insert(make_pair(plugin_name, library)); |
920 | } |
921 | + |
922 | return library; |
923 | } |
924 | |
925 | void module::Registry::removeLibrary(const std::string &plugin_name) |
926 | { |
927 | - LibraryMap::iterator iter= library_registry_.find(plugin_name); |
928 | + std::map<std::string, module::Library *>::iterator iter= |
929 | + library_registry_.find(plugin_name); |
930 | if (iter != library_registry_.end()) |
931 | { |
932 | + library_registry_.erase(iter); |
933 | delete iter->second; |
934 | - library_registry_.erase(iter); |
935 | } |
936 | } |
937 | |
938 | module::Library *module::Registry::findLibrary(const std::string &plugin_name) const |
939 | { |
940 | - return find_ptr2(library_registry_, plugin_name); |
941 | + LibraryMap::const_iterator iter= library_registry_.find(plugin_name); |
942 | + if (iter != library_registry_.end()) |
943 | + return iter->second; |
944 | + return NULL; |
945 | } |
946 | |
947 | void module::Registry::shutdownModules() |
948 | |
949 | === modified file 'drizzled/module/registry.h' |
950 | --- drizzled/module/registry.h 2011-07-25 04:35:53 +0000 |
951 | +++ drizzled/module/registry.h 2011-08-07 13:22:33 +0000 |
952 | @@ -25,24 +25,24 @@ |
953 | #include <algorithm> |
954 | #include <iosfwd> |
955 | |
956 | -#include <boost/algorithm/string.hpp> |
957 | #include <boost/scoped_ptr.hpp> |
958 | |
959 | #include <drizzled/gettext.h> |
960 | #include <drizzled/unireg.h> |
961 | #include <drizzled/errmsg_print.h> |
962 | #include <drizzled/plugin/plugin.h> |
963 | -#include <drizzled/util/find_ptr.h> |
964 | + |
965 | |
966 | namespace drizzled { |
967 | namespace module { |
968 | |
969 | -class Registry : boost::noncopyable |
970 | +class Registry |
971 | { |
972 | public: |
973 | - typedef std::map<std::string, Library*> LibraryMap; |
974 | - typedef std::map<std::string, Module*> ModuleMap; |
975 | - typedef std::vector<Module*> ModuleList; |
976 | + |
977 | + typedef std::map<std::string, Library *> LibraryMap; |
978 | + typedef std::map<std::string, Module *> ModuleMap; |
979 | + typedef std::vector<Module *> ModuleList; |
980 | private: |
981 | LibraryMap library_registry_; |
982 | ModuleMap module_registry_; |
983 | @@ -53,6 +53,8 @@ |
984 | bool deps_built_; |
985 | |
986 | Registry(); |
987 | + Registry(const Registry&); |
988 | + Registry& operator=(const Registry&); |
989 | ~Registry(); |
990 | |
991 | void buildDeps(); |
992 | @@ -60,18 +62,21 @@ |
993 | |
994 | static Registry& singleton() |
995 | { |
996 | - static Registry* registry= new Registry(); |
997 | + static Registry *registry= new Registry(); |
998 | return *registry; |
999 | } |
1000 | |
1001 | + void copy(plugin::Plugin::vector &arg); |
1002 | + |
1003 | static void shutdown(); |
1004 | |
1005 | - Module* find(const std::string&); |
1006 | - |
1007 | - void add(Module*); |
1008 | - void remove(Module*); |
1009 | - |
1010 | - ModuleList getList(); |
1011 | + Module *find(std::string name); |
1012 | + |
1013 | + void add(Module *module); |
1014 | + |
1015 | + void remove(Module *module); |
1016 | + |
1017 | + std::vector<Module *> getList(); |
1018 | |
1019 | const plugin::Plugin::map &getPluginsMap() const |
1020 | { |
1021 | @@ -93,21 +98,32 @@ |
1022 | void add(T *plugin) |
1023 | { |
1024 | bool failed= false; |
1025 | - std::string plugin_type(boost::to_lower_copy(plugin->getTypeName())); |
1026 | - std::string plugin_name(boost::to_lower_copy(plugin->getName())); |
1027 | - if (find_ptr(plugin_registry, std::make_pair(plugin_type, plugin_name))) |
1028 | - { |
1029 | - errmsg_printf(error::ERROR, _("Loading plugin %s failed: a %s plugin by that name already exists.\n"), |
1030 | - plugin->getTypeName().c_str(), plugin->getName().c_str()); |
1031 | - failed= true; |
1032 | - } |
1033 | - if (T::addPlugin(plugin)) // Olaf: Should addPlugin be called when failed is already true? |
1034 | - failed= true; |
1035 | + std::string plugin_type(plugin->getTypeName()); |
1036 | + std::transform(plugin_type.begin(), plugin_type.end(), |
1037 | + plugin_type.begin(), ::tolower); |
1038 | + std::string plugin_name(plugin->getName()); |
1039 | + std::transform(plugin_name.begin(), plugin_name.end(), |
1040 | + plugin_name.begin(), ::tolower); |
1041 | + if (plugin_registry.find(std::make_pair(plugin_type, plugin_name)) != plugin_registry.end()) |
1042 | + { |
1043 | + errmsg_printf(error::ERROR, |
1044 | + _("Loading plugin %s failed: a %s plugin by that name " |
1045 | + "already exists.\n"), |
1046 | + plugin->getTypeName().c_str(), |
1047 | + plugin->getName().c_str()); |
1048 | + failed= true; |
1049 | + } |
1050 | + if (T::addPlugin(plugin)) |
1051 | + { |
1052 | + failed= true; |
1053 | + } |
1054 | |
1055 | if (failed) |
1056 | { |
1057 | - errmsg_printf(error::ERROR, _("Fatal error: Failed initializing %s::%s plugin.\n"), |
1058 | - plugin->getTypeName().c_str(), plugin->getName().c_str()); |
1059 | + errmsg_printf(error::ERROR, |
1060 | + _("Fatal error: Failed initializing %s::%s plugin.\n"), |
1061 | + plugin->getTypeName().c_str(), |
1062 | + plugin->getName().c_str()); |
1063 | unireg_abort(1); |
1064 | } |
1065 | plugin_registry.insert(std::make_pair(std::make_pair(plugin_type, plugin_name), plugin)); |
1066 | @@ -116,8 +132,12 @@ |
1067 | template<class T> |
1068 | void remove(T *plugin) |
1069 | { |
1070 | - std::string plugin_type(boost::to_lower_copy(plugin->getTypeName())); |
1071 | - std::string plugin_name(boost::to_lower_copy(plugin->getName())); |
1072 | + std::string plugin_type(plugin->getTypeName()); |
1073 | + std::transform(plugin_type.begin(), plugin_type.end(), |
1074 | + plugin_type.begin(), ::tolower); |
1075 | + std::string plugin_name(plugin->getName()); |
1076 | + std::transform(plugin_name.begin(), plugin_name.end(), |
1077 | + plugin_name.begin(), ::tolower); |
1078 | T::removePlugin(plugin); |
1079 | plugin_registry.erase(std::make_pair(plugin_type, plugin_name)); |
1080 | } |
1081 | |
1082 | === modified file 'drizzled/parser.cc' |
1083 | --- drizzled/parser.cc 2011-08-03 10:04:55 +0000 |
1084 | +++ drizzled/parser.cc 2011-08-07 13:22:33 +0000 |
1085 | @@ -597,6 +597,15 @@ |
1086 | return DRIZZLE_TYPE_UUID; |
1087 | } |
1088 | |
1089 | +drizzled::enum_field_types buildIPv6Column(LEX *lex) |
1090 | +{ |
1091 | + if (lex->field()) |
1092 | + lex->field()->set_type(message::Table::Field::IPV6); |
1093 | + |
1094 | + return DRIZZLE_TYPE_IPV6; |
1095 | +} |
1096 | + |
1097 | + |
1098 | drizzled::enum_field_types buildDoubleColumn(LEX *lex) |
1099 | { |
1100 | if (lex->field()) |
1101 | |
1102 | === modified file 'drizzled/parser.h' |
1103 | --- drizzled/parser.h 2011-08-03 10:04:55 +0000 |
1104 | +++ drizzled/parser.h 2011-08-07 13:22:33 +0000 |
1105 | @@ -147,6 +147,7 @@ |
1106 | drizzled::enum_field_types buildBlobColumn(LEX *lex); |
1107 | drizzled::enum_field_types buildBooleanColumn(LEX *lex); |
1108 | drizzled::enum_field_types buildUuidColumn(LEX *lex); |
1109 | +drizzled::enum_field_types buildIPv6Column(LEX *lex); |
1110 | drizzled::enum_field_types buildDoubleColumn(LEX *lex); |
1111 | drizzled::enum_field_types buildTimestampColumn(LEX *lex, const char *length); |
1112 | drizzled::enum_field_types buildDecimalColumn(LEX *lex); |
1113 | |
1114 | === modified file 'drizzled/plugin/listen.cc' |
1115 | --- drizzled/plugin/listen.cc 2011-06-09 15:47:07 +0000 |
1116 | +++ drizzled/plugin/listen.cc 2011-08-07 13:22:33 +0000 |
1117 | @@ -32,16 +32,18 @@ |
1118 | |
1119 | #include <poll.h> |
1120 | |
1121 | -namespace drizzled { |
1122 | -namespace plugin { |
1123 | +namespace drizzled |
1124 | +{ |
1125 | +namespace plugin |
1126 | +{ |
1127 | |
1128 | -static std::vector<plugin::Listen*> listen_list; |
1129 | -std::vector<plugin::Listen*> listen_fd_list; |
1130 | +static std::vector<plugin::Listen *> listen_list; |
1131 | +std::vector<plugin::Listen *> listen_fd_list; |
1132 | std::vector<pollfd> fd_list; |
1133 | uint32_t fd_count= 0; |
1134 | int wakeup_pipe[2]; |
1135 | |
1136 | -ListenVector& Listen::getListenProtocols() |
1137 | +ListenVector &Listen::getListenProtocols() |
1138 | { |
1139 | return listen_list; |
1140 | } |
1141 | @@ -54,34 +56,42 @@ |
1142 | |
1143 | void Listen::removePlugin(plugin::Listen *listen_obj) |
1144 | { |
1145 | - listen_list.erase(std::remove(listen_list.begin(), listen_list.end(), listen_obj), listen_list.end()); |
1146 | + listen_list.erase(std::remove(listen_list.begin(), |
1147 | + listen_list.end(), |
1148 | + listen_obj), |
1149 | + listen_list.end()); |
1150 | } |
1151 | |
1152 | -bool Listen::setup() |
1153 | +bool Listen::setup(void) |
1154 | { |
1155 | - BOOST_FOREACH(plugin::Listen* it, listen_list) |
1156 | + std::vector<plugin::Listen *>::iterator it; |
1157 | + |
1158 | + for (it= listen_list.begin(); it < listen_list.end(); ++it) |
1159 | { |
1160 | std::vector<int> fds; |
1161 | - if (it->getFileDescriptors(fds)) |
1162 | + std::vector<int>::iterator fd; |
1163 | + |
1164 | + if ((*it)->getFileDescriptors(fds)) |
1165 | { |
1166 | errmsg_printf(error::ERROR, _("Error getting file descriptors")); |
1167 | return true; |
1168 | } |
1169 | |
1170 | fd_list.resize(fd_count + fds.size() + 1); |
1171 | - |
1172 | - BOOST_FOREACH(int fd, fds) |
1173 | + |
1174 | + for (fd= fds.begin(); fd < fds.end(); ++fd) |
1175 | { |
1176 | - fd_list[fd_count].fd= fd; |
1177 | + fd_list[fd_count].fd= *fd; |
1178 | fd_list[fd_count].events= POLLIN | POLLERR; |
1179 | - listen_fd_list.push_back(it); |
1180 | + listen_fd_list.push_back(*it); |
1181 | fd_count++; |
1182 | } |
1183 | } |
1184 | |
1185 | if (fd_count == 0) |
1186 | { |
1187 | - errmsg_printf(error::ERROR, _("No sockets could be bound for listening")); |
1188 | + errmsg_printf(error::ERROR, |
1189 | + _("No sockets could be bound for listening")); |
1190 | return true; |
1191 | } |
1192 | |
1193 | @@ -104,17 +114,21 @@ |
1194 | return false; |
1195 | } |
1196 | |
1197 | -Client *plugin::Listen::getClient() |
1198 | +Client *plugin::Listen::getClient(void) |
1199 | { |
1200 | + int ready; |
1201 | + plugin::Client *client; |
1202 | + |
1203 | while (1) |
1204 | { |
1205 | - int ready= poll(&fd_list[0], fd_count, -1); |
1206 | + ready= poll(&fd_list[0], fd_count, -1); |
1207 | if (ready == -1) |
1208 | { |
1209 | if (errno != EINTR) |
1210 | { |
1211 | sql_perror("poll()"); |
1212 | } |
1213 | + |
1214 | continue; |
1215 | } |
1216 | else if (ready == 0) |
1217 | @@ -142,22 +156,25 @@ |
1218 | return NULL; |
1219 | } |
1220 | |
1221 | - if (plugin::Client* client= listen_fd_list[x]->getClient(fd_list[x].fd)) |
1222 | - return client; |
1223 | + if (!(client= listen_fd_list[x]->getClient(fd_list[x].fd))) |
1224 | + continue; |
1225 | + |
1226 | + return client; |
1227 | } |
1228 | } |
1229 | } |
1230 | |
1231 | -Client *plugin::Listen::getNullClient() |
1232 | +Client *plugin::Listen::getNullClient(void) |
1233 | { |
1234 | return new plugin::NullClient(); |
1235 | } |
1236 | |
1237 | -void Listen::shutdown() |
1238 | +void Listen::shutdown(void) |
1239 | { |
1240 | ssize_t ret= write(wakeup_pipe[1], "\0", 1); |
1241 | assert(ret == 1); |
1242 | } |
1243 | |
1244 | + |
1245 | } /* namespace plugin */ |
1246 | } /* namespace drizzled */ |
1247 | |
1248 | === modified file 'drizzled/sql_table.cc' |
1249 | --- drizzled/sql_table.cc 2011-07-07 13:41:07 +0000 |
1250 | +++ drizzled/sql_table.cc 2011-08-07 13:22:33 +0000 |
1251 | @@ -503,6 +503,7 @@ |
1252 | case DRIZZLE_TYPE_NULL: |
1253 | case DRIZZLE_TYPE_TIME: |
1254 | case DRIZZLE_TYPE_UUID: |
1255 | + case DRIZZLE_TYPE_IPV6: |
1256 | case DRIZZLE_TYPE_VARCHAR: |
1257 | break; |
1258 | } |
1259 | |
1260 | === modified file 'drizzled/sql_yacc.yy' |
1261 | --- drizzled/sql_yacc.yy 2011-08-04 08:13:04 +0000 |
1262 | +++ drizzled/sql_yacc.yy 2011-08-07 13:22:33 +0000 |
1263 | @@ -365,6 +365,7 @@ |
1264 | %token IS /* SQL-2003-R */ |
1265 | %token ISOLATION /* SQL-2003-R */ |
1266 | %token ITERATE_SYM |
1267 | +%token IPV6_SYM |
1268 | %token JOIN_SYM /* SQL-2003-R */ |
1269 | %token KEYS |
1270 | %token KEY_BLOCK_SIZE |
1271 | @@ -1335,6 +1336,10 @@ |
1272 | { |
1273 | $$= parser::buildUuidColumn(&Lex); |
1274 | } |
1275 | + | IPV6_SYM opt_attribute |
1276 | + { |
1277 | + $$= parser::buildIPv6Column(&Lex); |
1278 | + } |
1279 | | BOOLEAN_SYM opt_attribute_boolean |
1280 | { |
1281 | $$= parser::buildBooleanColumn(&Lex); |
1282 | @@ -3047,6 +3052,14 @@ |
1283 | } |
1284 | Lex.setCacheable(false); |
1285 | } |
1286 | + | IPV6_SYM '(' ')' |
1287 | + { |
1288 | + if (! ($$= parser::reserved_keyword_function(YYSession, "ipv6", NULL))) |
1289 | + { |
1290 | + DRIZZLE_YYABORT; |
1291 | + } |
1292 | + Lex.setCacheable(false); |
1293 | + } |
1294 | | WAIT_SYM '(' expr ',' expr ')' |
1295 | { |
1296 | List<Item> *args= new (YYSession->mem_root) List<Item>; |
1297 | @@ -5301,6 +5314,7 @@ |
1298 | | IMPORT {} |
1299 | | INDEXES {} |
1300 | | ISOLATION {} |
1301 | + | IPV6_SYM {} |
1302 | | KEY_BLOCK_SIZE {} |
1303 | | LAST_SYM {} |
1304 | | LEVEL_SYM {} |
1305 | |
1306 | === modified file 'drizzled/symbol_hash.gperf' |
1307 | --- drizzled/symbol_hash.gperf 2011-07-01 18:59:28 +0000 |
1308 | +++ drizzled/symbol_hash.gperf 2011-08-07 13:22:33 +0000 |
1309 | @@ -209,6 +209,7 @@ |
1310 | IS, IS |
1311 | ISOLATION, ISOLATION |
1312 | ITERATE, ITERATE_SYM |
1313 | +IPV6, IPV6_SYM |
1314 | JOIN, JOIN_SYM |
1315 | KEY, KEY_SYM |
1316 | KEYS, KEYS |
1317 | |
1318 | === modified file 'drizzled/table/instance/base.cc' |
1319 | --- drizzled/table/instance/base.cc 2011-08-04 08:13:04 +0000 |
1320 | +++ drizzled/table/instance/base.cc 2011-08-07 13:22:33 +0000 |
1321 | @@ -80,6 +80,7 @@ |
1322 | #include <drizzled/field/microtime.h> |
1323 | #include <drizzled/field/varstring.h> |
1324 | #include <drizzled/field/uuid.h> |
1325 | +#include <drizzled/field/ipv6.h> |
1326 | #include <drizzled/plugin/storage_engine.h> |
1327 | #include <drizzled/definition/cache.h> |
1328 | #include <drizzled/typelib.h> |
1329 | @@ -132,6 +133,9 @@ |
1330 | case message::Table::Field::UUID: |
1331 | return DRIZZLE_TYPE_UUID; |
1332 | |
1333 | + case message::Table::Field::IPV6: |
1334 | + return DRIZZLE_TYPE_IPV6; |
1335 | + |
1336 | case message::Table::Field::BOOLEAN: |
1337 | return DRIZZLE_TYPE_BOOLEAN; |
1338 | |
1339 | @@ -185,6 +189,7 @@ |
1340 | case DRIZZLE_TYPE_DATE: |
1341 | case DRIZZLE_TYPE_ENUM: |
1342 | case DRIZZLE_TYPE_UUID: |
1343 | + case DRIZZLE_TYPE_IPV6: |
1344 | case DRIZZLE_TYPE_MICROTIME: |
1345 | case DRIZZLE_TYPE_BOOLEAN: |
1346 | default_item= new Item_string(default_value->c_str(), |
1347 | @@ -1169,6 +1174,9 @@ |
1348 | case DRIZZLE_TYPE_UUID: |
1349 | field_length= field::Uuid::max_string_length(); |
1350 | break; |
1351 | + case DRIZZLE_TYPE_IPV6: |
1352 | + field_length= field::IPv6::max_string_length(); |
1353 | + break; |
1354 | case DRIZZLE_TYPE_BOOLEAN: |
1355 | field_length= field::Boolean::max_string_length(); |
1356 | break; |
1357 | @@ -1228,6 +1236,7 @@ |
1358 | case DRIZZLE_TYPE_LONGLONG: |
1359 | case DRIZZLE_TYPE_NULL: |
1360 | case DRIZZLE_TYPE_UUID: |
1361 | + case DRIZZLE_TYPE_IPV6: |
1362 | case DRIZZLE_TYPE_BOOLEAN: |
1363 | break; |
1364 | } |
1365 | @@ -1955,6 +1964,12 @@ |
1366 | null_pos, |
1367 | null_bit, |
1368 | field_name); |
1369 | + case DRIZZLE_TYPE_IPV6: |
1370 | + return new (&mem_root) field::IPv6(ptr, |
1371 | + field_length, |
1372 | + null_pos, |
1373 | + null_bit, |
1374 | + field_name); |
1375 | case DRIZZLE_TYPE_BOOLEAN: |
1376 | return new (&mem_root) field::Boolean(ptr, |
1377 | field_length, |
1378 | |
1379 | === modified file 'drizzled/table_proto.cc' |
1380 | --- drizzled/table_proto.cc 2011-07-24 16:27:12 +0000 |
1381 | +++ drizzled/table_proto.cc 2011-08-07 13:22:33 +0000 |
1382 | @@ -135,6 +135,7 @@ |
1383 | case message::Table::Field::DATE: |
1384 | case message::Table::Field::DATETIME: |
1385 | case message::Table::Field::UUID: |
1386 | + case message::Table::Field::IPV6: |
1387 | case message::Table::Field::TIME: |
1388 | case message::Table::Field::BOOLEAN: |
1389 | break; |
1390 | |
1391 | === added file 'drizzled/type/ipv6.h' |
1392 | --- drizzled/type/ipv6.h 1970-01-01 00:00:00 +0000 |
1393 | +++ drizzled/type/ipv6.h 2011-08-07 13:22:33 +0000 |
1394 | @@ -0,0 +1,470 @@ |
1395 | +/* |
1396 | + Original copyright header listed below. This comes via rsync. |
1397 | + Any additional changes are provided via the same license as the original. |
1398 | + |
1399 | + Copyright (C) 2011 Muhammad Umair |
1400 | + |
1401 | +*/ |
1402 | +/* |
1403 | + * Copyright (C) 1996-2001 Internet Software Consortium. |
1404 | + * |
1405 | + * Permission to use, copy, modify, and distribute this software for any |
1406 | + * purpose with or without fee is hereby granted, provided that the above |
1407 | + * copyright notice and this permission notice appear in all copies. |
1408 | + * |
1409 | + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM |
1410 | + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL |
1411 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL |
1412 | + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, |
1413 | + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
1414 | + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
1415 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
1416 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
1417 | + */ |
1418 | + |
1419 | + |
1420 | +#ifndef DRIZZLED_TYPE_IPV6_ADDRESS_H_INCLUDED |
1421 | +#define DRIZZLED_TYPE_IPV6_ADDRESS_H_INCLUDED |
1422 | + |
1423 | + |
1424 | + |
1425 | +#include<cstdio> |
1426 | +#include<cstring> |
1427 | +#include <iostream> |
1428 | + |
1429 | + |
1430 | +namespace drizzled |
1431 | +{ |
1432 | +namespace type |
1433 | +{ |
1434 | + |
1435 | +class IPv6 { |
1436 | + |
1437 | + struct ipv6_ds |
1438 | + { |
1439 | + unsigned short ip6[8]; |
1440 | + }str; |
1441 | + |
1442 | + //Function to store the IPv4 address in IPv6 Data Structure |
1443 | + int ipv4_inet_pton(const char *src) |
1444 | + { |
1445 | + |
1446 | + char *ptr_src ; |
1447 | + |
1448 | + char ipv6h[20],ipv4[16], octet_h[5],octet_h1[5],group[20]; |
1449 | + int octet[4],octet_index = 0; |
1450 | + |
1451 | + memset(ipv6h, NULL, sizeof(ipv6h)); |
1452 | + strcpy(ipv6h,src); |
1453 | + |
1454 | + memset(octet, NULL, sizeof(octet)); |
1455 | + memset(ipv4, NULL, sizeof(ipv4)); |
1456 | + memset(octet_h, NULL, sizeof(octet_h)); |
1457 | + memset(octet_h1, NULL, sizeof(octet_h1)); |
1458 | + memset(group, NULL, sizeof(group)); |
1459 | + |
1460 | + ptr_src = strtok(ipv6h,"::"); |
1461 | + |
1462 | + strcpy(ipv4,ptr_src); |
1463 | + |
1464 | + ptr_src = strtok(ipv4,"."); |
1465 | + |
1466 | + while (ptr_src != '\0') |
1467 | + { |
1468 | + |
1469 | + sscanf( ptr_src,"%d", &octet[octet_index]); |
1470 | + |
1471 | + if(octet[octet_index++] > 255) |
1472 | + { |
1473 | + return 0; // Invalid IP Address |
1474 | + } |
1475 | + |
1476 | + ptr_src = strtok (NULL, "."); |
1477 | + |
1478 | + }// end of main while loop |
1479 | + |
1480 | + |
1481 | + if(octet_index < 4 || octet_index > 4) |
1482 | + { |
1483 | + return 0; // Invalid IP Address |
1484 | + } |
1485 | + |
1486 | + |
1487 | + octet_index = 0; |
1488 | + |
1489 | + str.ip6[0] = str.ip6[1] = str.ip6[2] = str.ip6[3] = str.ip6[4] = str.ip6[5] =0; |
1490 | + |
1491 | + for (int i=6 ; i <= 7; i++) |
1492 | + { |
1493 | + if (i == 7) |
1494 | + { |
1495 | + ++octet_index; |
1496 | + } |
1497 | + |
1498 | + sprintf(octet_h, "%02x", octet[octet_index]); |
1499 | + |
1500 | + sprintf(octet_h1, "%02x", octet[++octet_index]); |
1501 | + |
1502 | + strcpy(group,octet_h); |
1503 | + |
1504 | + strcat(group,octet_h1); |
1505 | + |
1506 | + sscanf(group,"%x",(unsigned int *)&str.ip6[i]); |
1507 | + |
1508 | + memset(octet_h, NULL, sizeof(octet_h)); |
1509 | + |
1510 | + memset(octet_h1, NULL, sizeof(octet_h1)); |
1511 | + |
1512 | + memset(group, NULL, sizeof(group)); |
1513 | + } |
1514 | + |
1515 | + return 1; |
1516 | + }//end of ipv4_inet_pton() function |
1517 | + |
1518 | + //Function to retain the IPv4 address from IPv6 Data Structure |
1519 | + char * ipv4_inet_ntop(char *destination) |
1520 | + { |
1521 | + |
1522 | + memset(destination,NULL,sizeof(destination)); |
1523 | + |
1524 | + sprintf( destination , "%03x:%03x:%03x:%03x:%03x:%03x:%03d.%03d.%03d.%03d" , |
1525 | + str.ip6[0],str.ip6[1],str.ip6[2],str.ip6[3],str.ip6[4],str.ip6[5], |
1526 | + (((unsigned int )str.ip6[6]>>8) & 0xFF), |
1527 | + ((unsigned int )str.ip6[6] & 0xFF), |
1528 | + (((unsigned int )str.ip6[7]>>8) & 0xFF), |
1529 | + ((unsigned int )str.ip6[7] & 0xFF)); |
1530 | + |
1531 | + return destination; |
1532 | + |
1533 | + }// end of ipv4_inet_ntop function |
1534 | + |
1535 | + |
1536 | + //Function to store the IPv6 address in IPv6 Data Structure |
1537 | + int ipv6_inet_pton(const char *src) |
1538 | + { |
1539 | + //Local variables |
1540 | + char ipv6[IPV6_BUFFER_LENGTH]; |
1541 | + |
1542 | + memset(ipv6,NULL,IPV6_BUFFER_LENGTH); |
1543 | + |
1544 | + strcpy(ipv6,src); |
1545 | + |
1546 | + char ipv6_temp[IPV6_BUFFER_LENGTH], ipv6_temp1[IPV6_BUFFER_LENGTH], ipv6_temp2[IPV6_BUFFER_LENGTH]; |
1547 | + |
1548 | + memset(ipv6_temp,NULL,IPV6_BUFFER_LENGTH); |
1549 | + |
1550 | + strcpy(ipv6_temp,ipv6); |
1551 | + |
1552 | + memset(ipv6_temp1,NULL,IPV6_BUFFER_LENGTH); |
1553 | + |
1554 | + strcpy(ipv6_temp1,ipv6); |
1555 | + |
1556 | + memset(ipv6_temp2,NULL,IPV6_BUFFER_LENGTH); |
1557 | + |
1558 | + strcpy(ipv6_temp2,ipv6); |
1559 | + |
1560 | + |
1561 | + static const char hex[] = "0123456789abcdef"; |
1562 | + char temp[IPV6_BUFFER_LENGTH]; |
1563 | + char *ptr_src ,*ptr_char, *ptr_src1; |
1564 | + const char *char_ptr_src; // get the src char |
1565 | + int char_int = NULL, index_ip6 = 0 ,octet_count=0, not_colon = 0, col =0, count_col = 0; |
1566 | + char temp_first[IPV6_BUFFER_LENGTH],temp_end[IPV6_BUFFER_LENGTH]; |
1567 | + |
1568 | + memset(temp_first, NULL,IPV6_BUFFER_LENGTH); |
1569 | + |
1570 | + memset(temp_end, NULL,IPV6_BUFFER_LENGTH); |
1571 | + |
1572 | +/* |
1573 | + if (sizeof(ipv6) > IPV6_BUFFER_LENGTH) |
1574 | + { |
1575 | + return (0); //Invalid IP Address |
1576 | + } |
1577 | + |
1578 | +*/ |
1579 | + ptr_src = ipv6; |
1580 | + //while loop check three consective colons |
1581 | + while (*ptr_src != '\0') |
1582 | + { |
1583 | + |
1584 | + if (*ptr_src == ':' && *++ptr_src == ':' && *++ptr_src == ':') |
1585 | + { |
1586 | + return 0; // Invalid IP Address |
1587 | + } |
1588 | + |
1589 | + ++ptr_src; |
1590 | + } |
1591 | + |
1592 | + //while loop count the total number of octets |
1593 | + ptr_src = strtok (ipv6_temp2,":"); |
1594 | + |
1595 | + |
1596 | + while (ptr_src != NULL) |
1597 | + { |
1598 | + octet_count++; |
1599 | + |
1600 | + ptr_src = strtok (NULL, ":"); |
1601 | + } |
1602 | + |
1603 | + //Retrun zero if total number of octets are greater than 8 |
1604 | + if(octet_count > 8) |
1605 | + { |
1606 | + return 0 ; // Invalid IP Address |
1607 | + } |
1608 | + |
1609 | + int num_miss_octet =0, size =0; |
1610 | + |
1611 | + |
1612 | + num_miss_octet = 8 - octet_count; |
1613 | + size = 2*num_miss_octet +1; |
1614 | + |
1615 | + char * zero_append = new char[size]; |
1616 | + |
1617 | + |
1618 | + memset(zero_append,NULL,sizeof(zero_append)); |
1619 | + |
1620 | + |
1621 | + ptr_src = ipv6_temp; |
1622 | + |
1623 | + //while loop locate the "::" position (start,middle or end) |
1624 | + while(*ptr_src != '\0') |
1625 | + { |
1626 | + if(*ptr_src == ':' && *++ptr_src == ':') |
1627 | + { |
1628 | + if (*++ptr_src=='\0') |
1629 | + { |
1630 | + col =2; |
1631 | + } |
1632 | + else if (not_colon == 0) |
1633 | + { |
1634 | + col=1; |
1635 | + } |
1636 | + else |
1637 | + { |
1638 | + col=3; |
1639 | + } |
1640 | + |
1641 | + count_col++; |
1642 | + |
1643 | + if(count_col == 2) |
1644 | + { |
1645 | + return 0; // Invalid IP Address. Ther must be single time double colon '::' |
1646 | + } |
1647 | + } |
1648 | + |
1649 | + ptr_src++; |
1650 | + not_colon++; |
1651 | + }// end of while loop |
1652 | + |
1653 | + // if col = 0 means the IPv6 Address string is in presffered form otherwise first it covert it into prefeered form |
1654 | + if(col>0) |
1655 | + { |
1656 | + //zero padding format according to the '::' position |
1657 | + strcpy(zero_append,""); |
1658 | + |
1659 | + |
1660 | + for (int i= 0; i < num_miss_octet; i++) |
1661 | + { |
1662 | + if(col==1) // start |
1663 | + { |
1664 | + strcat(zero_append,"0:"); |
1665 | + } |
1666 | + if(col==2 || col==3) //middle or end col =2 shows at end |
1667 | + { |
1668 | + strcat(zero_append,":0"); |
1669 | + } |
1670 | + } |
1671 | + if(col==3) |
1672 | + { |
1673 | + strcat(zero_append,":"); |
1674 | + } |
1675 | + |
1676 | + ptr_src = temp_end; |
1677 | + |
1678 | + if(col==1 || col==3) |
1679 | + { //only for start and middle |
1680 | + |
1681 | + ptr_src1 = strstr (ipv6_temp,"::"); |
1682 | + |
1683 | + ptr_src1 = ptr_src1+2; |
1684 | + |
1685 | + while(*ptr_src1 != '\0') |
1686 | + { |
1687 | + *ptr_src++ = *ptr_src1++; |
1688 | + |
1689 | + if(*ptr_src1 == '\0') |
1690 | + { |
1691 | + *ptr_src ='\0'; |
1692 | + } |
1693 | + } |
1694 | + } |
1695 | + |
1696 | + //copy the input IPv6 string before and after '::' |
1697 | + ptr_src1 = strstr (ipv6_temp1,"::"); |
1698 | + |
1699 | + *ptr_src1 ='\0'; |
1700 | + |
1701 | + |
1702 | + strcpy(temp_first,ipv6_temp1); |
1703 | + |
1704 | + if(col==2) // end |
1705 | + { |
1706 | + strcat(temp_first,zero_append); |
1707 | + } |
1708 | + else |
1709 | + { |
1710 | + strcat(temp_first,zero_append); |
1711 | + |
1712 | + strcat(temp_first,temp_end); |
1713 | + } |
1714 | + |
1715 | + memset(ipv6,NULL,IPV6_BUFFER_LENGTH); |
1716 | + |
1717 | + strcpy(ipv6,temp_first); |
1718 | + }// end of main if statement |
1719 | + |
1720 | + |
1721 | + |
1722 | + //while loop store each octet on ipv6 struture in decimal value of hexadecimal digits |
1723 | + ptr_char = temp; |
1724 | + |
1725 | + ptr_src = strtok (ipv6,":"); |
1726 | + |
1727 | + |
1728 | + while (ptr_src != NULL) |
1729 | + { |
1730 | + strcpy(temp, ptr_src); |
1731 | + |
1732 | + ptr_char = temp; |
1733 | + |
1734 | + int octet_length = strlen(ptr_char); |
1735 | + |
1736 | + *(ptr_char + octet_length) = '\0'; |
1737 | + |
1738 | + |
1739 | + while(*ptr_char != '\0') |
1740 | + { |
1741 | + char_int = tolower(*ptr_char); |
1742 | + |
1743 | + char_ptr_src = strchr (hex, char_int); |
1744 | + |
1745 | + if(char_ptr_src == NULL) |
1746 | + { |
1747 | + return 0; // Invalid IP Address |
1748 | + |
1749 | + } |
1750 | + |
1751 | + *ptr_char = *char_ptr_src; |
1752 | + ptr_char++; |
1753 | + }//end of inner while loop |
1754 | + |
1755 | + ptr_char-= octet_length; |
1756 | + |
1757 | + |
1758 | + unsigned int *ptr = (unsigned int *)&(str.ip6[index_ip6++]); |
1759 | + |
1760 | + sscanf( ptr_char,"%x", ptr); |
1761 | + |
1762 | + |
1763 | + memset(temp,NULL,IPV6_BUFFER_LENGTH); |
1764 | + |
1765 | + |
1766 | + ptr_src = strtok (NULL, ":"); |
1767 | + }// end of main while loop |
1768 | + |
1769 | + delete [] zero_append; |
1770 | + |
1771 | + return 1; |
1772 | + }// end of Ipv6_Inet_pton function |
1773 | + |
1774 | + //Function to retain the IPv6 address from IPv6 Data Structure |
1775 | + char* ipv6_inet_ntop(char *destination) |
1776 | + { |
1777 | + char temp[10]; |
1778 | + |
1779 | + memset(temp,NULL,sizeof(temp)); |
1780 | + |
1781 | + memset(destination,NULL,IPV6_BUFFER_LENGTH); |
1782 | + |
1783 | + |
1784 | + for (int i= 0; i <= 7; i++) |
1785 | + { |
1786 | + if(i==7) |
1787 | + { |
1788 | + sprintf(temp,"%04x",str.ip6[i]); |
1789 | + |
1790 | + strcat(destination,temp); |
1791 | + } |
1792 | + else |
1793 | + { |
1794 | + sprintf(temp,"%04x:",str.ip6[i]); |
1795 | + |
1796 | + strcat(destination,temp); |
1797 | + } |
1798 | + |
1799 | + memset(temp,NULL,sizeof(temp)); |
1800 | + } |
1801 | + |
1802 | + |
1803 | + return destination; |
1804 | + }// end of Ipv6_Inet_ntop function |
1805 | + |
1806 | + |
1807 | + public: |
1808 | + |
1809 | + IPv6() |
1810 | + { |
1811 | + str.ip6[0] = str.ip6[1] = str.ip6[2] = str.ip6[3] = str.ip6[4] = str.ip6[5] = str.ip6[6] = str.ip6[7] = 0; |
1812 | + } |
1813 | + |
1814 | + |
1815 | + void store_object(unsigned char *out) |
1816 | + { |
1817 | + memcpy(out, (unsigned char *)&str, sizeof(str)); |
1818 | + } |
1819 | + |
1820 | + void restore_object(const unsigned char * in) |
1821 | + { |
1822 | + memcpy(&str, (struct ipv6_ds *)in, sizeof(str)); |
1823 | + } |
1824 | + |
1825 | + int inet_pton(const char *ip) |
1826 | + { |
1827 | + char * pch; |
1828 | + |
1829 | + pch=strchr((char *)ip,'.'); |
1830 | + |
1831 | + if(pch == NULL) |
1832 | + { |
1833 | + return ipv6_inet_pton(ip); |
1834 | + } |
1835 | + else |
1836 | + { |
1837 | + return ipv4_inet_pton(ip); |
1838 | + } |
1839 | + } |
1840 | + |
1841 | + char * inet_ntop(char *dest) |
1842 | + { |
1843 | + if (str.ip6[0]==0 && str.ip6[1]==0 && str.ip6[2]==0 && str.ip6[3]==0 && str.ip6[4]==0 && str.ip6[5]==0 && str.ip6[6]!=0) |
1844 | + { |
1845 | + return ipv4_inet_ntop(dest); |
1846 | + } |
1847 | + else |
1848 | + { |
1849 | + return ipv6_inet_ntop(dest); |
1850 | + } |
1851 | + } |
1852 | + |
1853 | + |
1854 | + static const size_t LENGTH= 16; |
1855 | + static const size_t IPV6_DISPLAY_LENGTH= 39; |
1856 | + static const size_t IPV6_BUFFER_LENGTH= IPV6_DISPLAY_LENGTH+1; |
1857 | + |
1858 | +}; // endof class |
1859 | + |
1860 | + |
1861 | +} /* namespace type */ |
1862 | +} /* namespace drizzled */ |
1863 | + |
1864 | +#endif // DRIZZLED_TYPE_IPV6_ADDRESS_H_INCLUDED |
1865 | |
1866 | === modified file 'plugin/auth_file/auth_file.cc' |
1867 | --- plugin/auth_file/auth_file.cc 2011-06-21 12:02:57 +0000 |
1868 | +++ plugin/auth_file/auth_file.cc 2011-08-07 13:22:33 +0000 |
1869 | @@ -40,19 +40,23 @@ |
1870 | using namespace std; |
1871 | using namespace drizzled; |
1872 | |
1873 | -namespace auth_file { |
1874 | +namespace auth_file |
1875 | +{ |
1876 | |
1877 | static const fs::path DEFAULT_USERS_FILE= SYSCONFDIR "/drizzle.users"; |
1878 | |
1879 | -class AuthFile : public plugin::Authentication |
1880 | +class AuthFile: public plugin::Authentication |
1881 | { |
1882 | + const fs::path users_file; |
1883 | + |
1884 | public: |
1885 | - AuthFile(fs::path users_file_arg); |
1886 | + |
1887 | + AuthFile(string name_arg, fs::path users_file_arg); |
1888 | |
1889 | /** |
1890 | * Retrieve the last error encountered in the class. |
1891 | */ |
1892 | - const string& getError() const; |
1893 | + string& getError(void); |
1894 | |
1895 | /** |
1896 | * Load the users file into a map cache. |
1897 | @@ -60,7 +64,7 @@ |
1898 | * @return True on success, false on error. If false is returned an error |
1899 | * is set and can be retrieved with getError(). |
1900 | */ |
1901 | - bool loadFile(); |
1902 | + bool loadFile(void); |
1903 | |
1904 | private: |
1905 | |
1906 | @@ -85,41 +89,44 @@ |
1907 | const string &scrambled_password); |
1908 | |
1909 | string error; |
1910 | - const fs::path users_file; |
1911 | |
1912 | /** |
1913 | * Cache or username:password entries from the file. |
1914 | */ |
1915 | - typedef std::map<string, string> users_t; |
1916 | - users_t users; |
1917 | + std::map<string, string> users; |
1918 | }; |
1919 | |
1920 | -AuthFile::AuthFile(fs::path users_file_arg) : |
1921 | - plugin::Authentication("auth_file"), |
1922 | - users_file(users_file_arg) |
1923 | +AuthFile::AuthFile(string name_arg, fs::path users_file_arg): |
1924 | + plugin::Authentication(name_arg), |
1925 | + users_file(users_file_arg), |
1926 | + error(), |
1927 | + users() |
1928 | { |
1929 | } |
1930 | |
1931 | -const string& AuthFile::getError() const |
1932 | +string& AuthFile::getError(void) |
1933 | { |
1934 | return error; |
1935 | } |
1936 | |
1937 | -bool AuthFile::loadFile() |
1938 | +bool AuthFile::loadFile(void) |
1939 | { |
1940 | ifstream file(users_file.string().c_str()); |
1941 | |
1942 | if (!file.is_open()) |
1943 | { |
1944 | - error = "Could not open users file: " + users_file.string(); |
1945 | + error = "Could not open users file: "; |
1946 | + error += users_file.string(); |
1947 | return false; |
1948 | } |
1949 | |
1950 | - string line; |
1951 | - while (getline(file, line)) |
1952 | + while (!file.eof()) |
1953 | { |
1954 | + string line; |
1955 | + getline(file, line); |
1956 | + |
1957 | /* Ignore blank lines and lines starting with '#'. */ |
1958 | - if (line.empty() || line[line.find_first_not_of(" \t")] == '#') |
1959 | + if (line == "" || line[line.find_first_not_of(" \t")] == '#') |
1960 | continue; |
1961 | |
1962 | string username; |
1963 | @@ -133,12 +140,19 @@ |
1964 | password = string(line, password_offset + 1); |
1965 | } |
1966 | |
1967 | - if (not users.insert(pair<string, string>(username, password)).second) |
1968 | + std::pair<std::map<std::string, std::string>::iterator, bool> result= |
1969 | + users.insert(std::pair<std::string, std::string>(username, password)); |
1970 | + |
1971 | + if (result.second == false) |
1972 | { |
1973 | - error = "Duplicate entry found in users file: " + username; |
1974 | + error = "Duplicate entry found in users file: "; |
1975 | + error += username; |
1976 | + file.close(); |
1977 | return false; |
1978 | } |
1979 | } |
1980 | + |
1981 | + file.close(); |
1982 | return true; |
1983 | } |
1984 | |
1985 | @@ -146,7 +160,8 @@ |
1986 | const string &scramble_bytes, |
1987 | const string &scrambled_password) |
1988 | { |
1989 | - if (scramble_bytes.size() != SHA1_DIGEST_LENGTH || scrambled_password.size() != SHA1_DIGEST_LENGTH) |
1990 | + if (scramble_bytes.size() != SHA1_DIGEST_LENGTH || |
1991 | + scrambled_password.size() != SHA1_DIGEST_LENGTH) |
1992 | { |
1993 | return false; |
1994 | } |
1995 | @@ -158,7 +173,8 @@ |
1996 | |
1997 | /* Generate the double SHA1 hash for the password stored locally first. */ |
1998 | SHA1Init(&ctx); |
1999 | - SHA1Update(&ctx, reinterpret_cast<const uint8_t *>(password.c_str()), password.size()); |
2000 | + SHA1Update(&ctx, reinterpret_cast<const uint8_t *>(password.c_str()), |
2001 | + password.size()); |
2002 | SHA1Final(temp_hash, &ctx); |
2003 | |
2004 | SHA1Init(&ctx); |
2005 | @@ -167,7 +183,8 @@ |
2006 | |
2007 | /* Hash the scramble that was sent to client with the local password. */ |
2008 | SHA1Init(&ctx); |
2009 | - SHA1Update(&ctx, reinterpret_cast<const uint8_t*>(scramble_bytes.c_str()), SHA1_DIGEST_LENGTH); |
2010 | + SHA1Update(&ctx, reinterpret_cast<const uint8_t*>(scramble_bytes.c_str()), |
2011 | + SHA1_DIGEST_LENGTH); |
2012 | SHA1Update(&ctx, local_scrambled_password, SHA1_DIGEST_LENGTH); |
2013 | SHA1Final(temp_hash, &ctx); |
2014 | |
2015 | @@ -187,22 +204,28 @@ |
2016 | |
2017 | bool AuthFile::authenticate(const identifier::User &sctx, const string &password) |
2018 | { |
2019 | - string* user= find_ptr(users, sctx.username()); |
2020 | - if (not user) |
2021 | + std::map<std::string, std::string>::const_iterator user= users.find(sctx.username()); |
2022 | + if (user == users.end()) |
2023 | return false; |
2024 | - return sctx.getPasswordType() == identifier::User::MYSQL_HASH |
2025 | - ? verifyMySQLHash(*user, sctx.getPasswordContext(), password) |
2026 | - : password == *user; |
2027 | + |
2028 | + if (sctx.getPasswordType() == identifier::User::MYSQL_HASH) |
2029 | + return verifyMySQLHash(user->second, sctx.getPasswordContext(), password); |
2030 | + |
2031 | + if (password == user->second) |
2032 | + return true; |
2033 | + |
2034 | + return false; |
2035 | } |
2036 | |
2037 | static int init(module::Context &context) |
2038 | { |
2039 | const module::option_map &vm= context.getOptions(); |
2040 | |
2041 | - AuthFile *auth_file = new AuthFile(fs::path(vm["users"].as<string>())); |
2042 | + AuthFile *auth_file = new AuthFile("auth_file", fs::path(vm["users"].as<string>())); |
2043 | if (not auth_file->loadFile()) |
2044 | { |
2045 | - errmsg_printf(error::ERROR, _("Could not load auth file: %s\n"), auth_file->getError().c_str()); |
2046 | + errmsg_printf(error::ERROR, _("Could not load auth file: %s\n"), |
2047 | + auth_file->getError().c_str()); |
2048 | delete auth_file; |
2049 | return 1; |
2050 | } |
2051 | |
2052 | === modified file 'plugin/innobase/handler/ha_innodb.cc' |
2053 | --- plugin/innobase/handler/ha_innodb.cc 2011-07-25 14:24:19 +0000 |
2054 | +++ plugin/innobase/handler/ha_innodb.cc 2011-08-07 13:22:33 +0000 |
2055 | @@ -3903,6 +3903,8 @@ |
2056 | case DRIZZLE_TYPE_BLOB: |
2057 | return(DATA_BLOB); |
2058 | case DRIZZLE_TYPE_BOOLEAN: |
2059 | + case DRIZZLE_TYPE_IPV6: |
2060 | + return(DATA_FIXBINARY); |
2061 | case DRIZZLE_TYPE_UUID: |
2062 | return(DATA_FIXBINARY); |
2063 | case DRIZZLE_TYPE_NULL: |
2064 | |
2065 | === added directory 'plugin/ipv6_function' |
2066 | === added file 'plugin/ipv6_function/ipv6_function.cc' |
2067 | --- plugin/ipv6_function/ipv6_function.cc 1970-01-01 00:00:00 +0000 |
2068 | +++ plugin/ipv6_function/ipv6_function.cc 2011-08-07 13:22:33 +0000 |
2069 | @@ -0,0 +1,107 @@ |
2070 | +/* |
2071 | + Original copyright header listed below. This comes via rsync. |
2072 | + Any additional changes are provided via the same license as the original. |
2073 | + |
2074 | + Copyright (C) 2011 Muhammad Umair |
2075 | + |
2076 | +*/ |
2077 | +/* |
2078 | + * Copyright (C) 1996-2001 Internet Software Consortium. |
2079 | + * |
2080 | + * Permission to use, copy, modify, and distribute this software for any |
2081 | + * purpose with or without fee is hereby granted, provided that the above |
2082 | + * copyright notice and this permission notice appear in all copies. |
2083 | + * |
2084 | + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM |
2085 | + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL |
2086 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL |
2087 | + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, |
2088 | + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
2089 | + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
2090 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
2091 | + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
2092 | + */ |
2093 | + |
2094 | + |
2095 | +#include <config.h> |
2096 | +#include <drizzled/error.h> |
2097 | +#include <drizzled/charset.h> |
2098 | +#include <drizzled/function/str/strfunc.h> |
2099 | +#include <drizzled/item/func.h> |
2100 | +#include <drizzled/plugin/function.h> |
2101 | +#include <drizzled/type/ipv6.h> |
2102 | + |
2103 | + |
2104 | +namespace plugin { |
2105 | +namespace ipv6_function { |
2106 | + |
2107 | +class Generate: public drizzled::Item_str_func |
2108 | +{ |
2109 | +public: |
2110 | + Generate(): drizzled::Item_str_func() {} |
2111 | + void fix_length_and_dec() |
2112 | + { |
2113 | + |
2114 | + max_length= (drizzled::type::IPv6::IPV6_BUFFER_LENGTH) * drizzled::system_charset_info->mbmaxlen; |
2115 | + } |
2116 | + const char *func_name() const{ return "ipv6"; } |
2117 | + const char *fully_qualified_func_name() const { return "ipv6()"; } |
2118 | + drizzled::String *val_str(drizzled::String *); |
2119 | +}; |
2120 | + |
2121 | + |
2122 | +drizzled::String *Generate::val_str(drizzled::String *str) |
2123 | +{ |
2124 | + drizzled::String _result; |
2125 | + drizzled::String *result= val_str(&_result); |
2126 | + drizzled::type::IPv6 ptr_address; |
2127 | + |
2128 | + if (not ptr_address.inet_pton(result->c_str())) |
2129 | + { |
2130 | + drizzled::my_error(drizzled::ER_INVALID_IPV6_VALUE, MYF(ME_FATALERROR)); |
2131 | + str->length(0); |
2132 | + |
2133 | + return str; |
2134 | + } |
2135 | + |
2136 | + char *ipv6_string; |
2137 | + str->realloc(drizzled::type::IPv6::IPV6_BUFFER_LENGTH); |
2138 | + str->length(drizzled::type::IPv6::IPV6_BUFFER_LENGTH); |
2139 | + str->set_charset(drizzled::system_charset_info); |
2140 | + ipv6_string= (char *) str->ptr(); |
2141 | + |
2142 | + if (not ptr_address.inet_ntop(ipv6_string)) |
2143 | + { |
2144 | + drizzled::my_error(drizzled::ER_INVALID_IPV6_VALUE, MYF(ME_FATALERROR)); |
2145 | + str->length(0); |
2146 | + |
2147 | + return str; |
2148 | + } |
2149 | + str->length(max_length); |
2150 | + |
2151 | + return str; |
2152 | +} |
2153 | + |
2154 | +} // namespace ipv6_function |
2155 | +} // namespace plugin |
2156 | + |
2157 | +static int initialize(drizzled::module::Context &context) |
2158 | +{ |
2159 | + context.add(new drizzled::plugin::Create_function<plugin::ipv6_function::Generate>("ipv6")); |
2160 | + |
2161 | + return 0; |
2162 | +} |
2163 | + |
2164 | +DRIZZLE_DECLARE_PLUGIN |
2165 | +{ |
2166 | + DRIZZLE_VERSION_ID, |
2167 | + "ipv6", |
2168 | + "1.0", |
2169 | + "Muhammad Umair", |
2170 | + "IPV6() function", |
2171 | + drizzled::PLUGIN_LICENSE_GPL, |
2172 | + initialize, /* Plugin Init */ |
2173 | + NULL, /* depends */ |
2174 | + NULL /* config options */ |
2175 | +} |
2176 | +DRIZZLE_DECLARE_PLUGIN_END; |
2177 | |
2178 | === added file 'plugin/ipv6_function/plugin.ini' |
2179 | --- plugin/ipv6_function/plugin.ini 1970-01-01 00:00:00 +0000 |
2180 | +++ plugin/ipv6_function/plugin.ini 2011-08-07 13:22:33 +0000 |
2181 | @@ -0,0 +1,9 @@ |
2182 | +[plugin] |
2183 | +title=IPV6() plugin |
2184 | +author=Muhammad Umair |
2185 | +version=1.0 |
2186 | +license=PLUGIN_LICENSE_GPL |
2187 | +description=IPV6() function plugin |
2188 | +load_by_default=yes |
2189 | +sources= ipv6_function.cc |
2190 | +static=yes |
2191 | |
2192 | === modified file 'plugin/logging_stats/scoreboard.cc' |
2193 | --- plugin/logging_stats/scoreboard.cc 2011-07-05 16:50:17 +0000 |
2194 | +++ plugin/logging_stats/scoreboard.cc 2011-08-07 13:22:33 +0000 |
2195 | @@ -63,25 +63,39 @@ |
2196 | /* calculate the number of elements in each bucket */ |
2197 | number_per_bucket= static_cast<uint32_t> ( ceil( static_cast<double>(number_sessions) / static_cast<double>(number_buckets) ) ); |
2198 | |
2199 | - vector_of_scoreboard_vectors.reserve(number_buckets); |
2200 | /* populate the vector of scoreboard vectors */ |
2201 | for (uint32_t j= 0; j < number_buckets; ++j) |
2202 | { |
2203 | - vector<ScoreboardSlot* > *scoreboard_vector= new vector<ScoreboardSlot*>; |
2204 | + vector<ScoreboardSlot* > *scoreboard_vector= new vector<ScoreboardSlot* >(); |
2205 | |
2206 | - scoreboard_vector->reserve(number_per_bucket); |
2207 | /* preallocate the individual vectors */ |
2208 | + vector<ScoreboardSlot* >::iterator scoreboard_vector_iterator= scoreboard_vector->begin(); |
2209 | for (uint32_t h= 0; h < number_per_bucket; ++h) |
2210 | - scoreboard_vector->push_back(new ScoreboardSlot); |
2211 | + { |
2212 | + ScoreboardSlot *scoreboard_slot= new ScoreboardSlot(); |
2213 | + scoreboard_vector_iterator= scoreboard_vector->insert(scoreboard_vector_iterator, scoreboard_slot); |
2214 | + } |
2215 | + scoreboard_vector->resize(number_per_bucket); |
2216 | + |
2217 | |
2218 | /* insert the vector into the vector of scoreboard vectors */ |
2219 | - vector_of_scoreboard_vectors.push_back(scoreboard_vector); |
2220 | + vector<vector<ScoreboardSlot* >* >::iterator vector_of_scoreboard_vectors_iterator= |
2221 | + vector_of_scoreboard_vectors.begin(); |
2222 | + |
2223 | + vector_of_scoreboard_vectors_iterator= |
2224 | + vector_of_scoreboard_vectors.insert(vector_of_scoreboard_vectors_iterator, scoreboard_vector); |
2225 | } |
2226 | + vector_of_scoreboard_vectors.resize(number_buckets); |
2227 | |
2228 | - vector_of_scoreboard_locks.reserve(number_buckets); |
2229 | /* populate the scoreboard locks vector each ScoreboardSlot vector gets a lock */ |
2230 | + vector<boost::shared_mutex* >::iterator vector_of_scoreboard_locks_iterator= vector_of_scoreboard_locks.begin(); |
2231 | for (uint32_t k= 0; k < number_buckets; ++k) |
2232 | - vector_of_scoreboard_locks.push_back(new boost::shared_mutex); |
2233 | + { |
2234 | + boost::shared_mutex* lock= new boost::shared_mutex(); |
2235 | + vector_of_scoreboard_locks_iterator= |
2236 | + vector_of_scoreboard_locks.insert(vector_of_scoreboard_locks_iterator, lock); |
2237 | + } |
2238 | + vector_of_scoreboard_locks.resize(number_buckets); |
2239 | |
2240 | /* calculate the approximate memory allocation of the scoreboard */ |
2241 | size_t statusVarsSize= sizeof(StatusVars) + sizeof(system_status_var); |
2242 | @@ -92,19 +106,37 @@ |
2243 | |
2244 | Scoreboard::~Scoreboard() |
2245 | { |
2246 | - BOOST_FOREACH(std::vector<ScoreboardSlot*>* it0, vector_of_scoreboard_vectors) |
2247 | - { |
2248 | - BOOST_FOREACH(ScoreboardSlot* it, *it0) |
2249 | - delete it; |
2250 | - delete it0; |
2251 | + vector<vector<ScoreboardSlot* >* >::iterator v_of_scoreboard_v_begin_it= vector_of_scoreboard_vectors.begin(); |
2252 | + vector<vector<ScoreboardSlot* >* >::iterator v_of_scoreboard_v_end_it= vector_of_scoreboard_vectors.end(); |
2253 | + |
2254 | + for (; v_of_scoreboard_v_begin_it != v_of_scoreboard_v_end_it; ++v_of_scoreboard_v_begin_it) |
2255 | + { |
2256 | + vector<ScoreboardSlot* > *scoreboard_vector= *v_of_scoreboard_v_begin_it; |
2257 | + |
2258 | + vector<ScoreboardSlot* >::iterator scoreboard_vector_it= scoreboard_vector->begin(); |
2259 | + vector<ScoreboardSlot* >::iterator scoreboard_vector_end= scoreboard_vector->end(); |
2260 | + for (; scoreboard_vector_it != scoreboard_vector_end; ++scoreboard_vector_it) |
2261 | + { |
2262 | + delete *scoreboard_vector_it; |
2263 | + } |
2264 | + |
2265 | + scoreboard_vector->clear(); |
2266 | + delete scoreboard_vector; |
2267 | + } // vector_of_scoreboard_vectors is not on the stack and does not deletion |
2268 | + |
2269 | + vector<boost::shared_mutex* >::iterator vector_of_scoreboard_locks_it= vector_of_scoreboard_locks.begin(); |
2270 | + vector<boost::shared_mutex* >::iterator vector_of_scoreboard_locks_end= vector_of_scoreboard_locks.end(); |
2271 | + |
2272 | + for (; vector_of_scoreboard_locks_it != vector_of_scoreboard_locks_end; ++vector_of_scoreboard_locks_it) |
2273 | + { |
2274 | + boost::shared_mutex* lock= *vector_of_scoreboard_locks_it; |
2275 | + delete lock; |
2276 | } |
2277 | - BOOST_FOREACH(boost::shared_mutex* it, vector_of_scoreboard_locks) |
2278 | - delete it; |
2279 | } |
2280 | |
2281 | -uint32_t Scoreboard::getBucketNumber(Session *session) const |
2282 | +uint32_t Scoreboard::getBucketNumber(Session *session) |
2283 | { |
2284 | - return session->getSessionId() % number_buckets; |
2285 | + return (session->getSessionId() % number_buckets); |
2286 | } |
2287 | |
2288 | ScoreboardSlot* Scoreboard::findScoreboardSlotToLog(Session *session) |
2289 | @@ -118,29 +150,39 @@ |
2290 | /* Check if this session has already claimed a slot */ |
2291 | int32_t session_scoreboard_slot= session->getScoreboardIndex(); |
2292 | |
2293 | - if (session_scoreboard_slot != -1) |
2294 | - return scoreboard_vector->at(session_scoreboard_slot); |
2295 | - |
2296 | - boost::shared_mutex* LOCK_scoreboard_vector= vector_of_scoreboard_locks.at(bucket_number); |
2297 | - LOCK_scoreboard_vector->lock(); |
2298 | - |
2299 | - int32_t slot_index= 0; |
2300 | - for (vector<ScoreboardSlot*>::iterator it= scoreboard_vector->begin(); it != scoreboard_vector->end(); ++it, ++slot_index) |
2301 | - { |
2302 | - ScoreboardSlot& slot= **it; |
2303 | - if (slot.isInUse()) |
2304 | - continue; |
2305 | - slot.setInUse(true); |
2306 | - slot.setSessionId(session->getSessionId()); |
2307 | - slot.setUser(session->user()->username()); |
2308 | - slot.setIp(session->user()->address()); |
2309 | - session->setScoreboardIndex(slot_index); |
2310 | - LOCK_scoreboard_vector->unlock(); |
2311 | - return &slot; |
2312 | + if (session_scoreboard_slot == -1) |
2313 | + { |
2314 | + boost::shared_mutex* LOCK_scoreboard_vector= vector_of_scoreboard_locks.at(bucket_number); |
2315 | + LOCK_scoreboard_vector->lock(); |
2316 | + |
2317 | + ScoreboardSlot *scoreboard_slot= NULL; |
2318 | + |
2319 | + int32_t slot_index= 0; |
2320 | + for (vector<ScoreboardSlot *>::iterator it= scoreboard_vector->begin(); |
2321 | + it != scoreboard_vector->end(); ++it, ++slot_index) |
2322 | + { |
2323 | + scoreboard_slot= *it; |
2324 | + |
2325 | + if (scoreboard_slot->isInUse() == false) |
2326 | + { |
2327 | + scoreboard_slot->setInUse(true); |
2328 | + scoreboard_slot->setSessionId(session->getSessionId()); |
2329 | + scoreboard_slot->setUser(session->user()->username()); |
2330 | + scoreboard_slot->setIp(session->user()->address()); |
2331 | + session->setScoreboardIndex(slot_index); |
2332 | + LOCK_scoreboard_vector->unlock(); |
2333 | + return scoreboard_slot; |
2334 | + } |
2335 | + } |
2336 | + |
2337 | + LOCK_scoreboard_vector->unlock(); |
2338 | + } |
2339 | + else // already claimed a slot just do a lookup |
2340 | + { |
2341 | + ScoreboardSlot *scoreboard_slot= scoreboard_vector->at(session_scoreboard_slot); |
2342 | + return scoreboard_slot; |
2343 | } |
2344 | |
2345 | - LOCK_scoreboard_vector->unlock(); |
2346 | - |
2347 | /* its possible we did not claim a slot if the scoreboard size is somehow smaller then the |
2348 | active connections */ |
2349 | return NULL; |
2350 | @@ -148,9 +190,20 @@ |
2351 | |
2352 | ScoreboardSlot* Scoreboard::findOurScoreboardSlot(Session *session) |
2353 | { |
2354 | + /* our bucket */ |
2355 | + uint32_t bucket_number= getBucketNumber(session); |
2356 | + |
2357 | + /* our vector corresponding to bucket_number */ |
2358 | + vector<ScoreboardSlot* > *scoreboard_vector= vector_of_scoreboard_vectors.at(bucket_number); |
2359 | + |
2360 | /* Check if this session has already claimed a slot */ |
2361 | int32_t session_scoreboard_slot= session->getScoreboardIndex(); |
2362 | + |
2363 | if (session_scoreboard_slot == -1) |
2364 | + { |
2365 | return NULL; |
2366 | - return vector_of_scoreboard_vectors.at(getBucketNumber(session))->at(session_scoreboard_slot); |
2367 | + } |
2368 | + |
2369 | + ScoreboardSlot *scoreboard_slot= scoreboard_vector->at(session_scoreboard_slot); |
2370 | + return scoreboard_slot; |
2371 | } |
2372 | |
2373 | === modified file 'plugin/logging_stats/scoreboard.h' |
2374 | --- plugin/logging_stats/scoreboard.h 2011-07-05 16:50:17 +0000 |
2375 | +++ plugin/logging_stats/scoreboard.h 2011-08-07 13:22:33 +0000 |
2376 | @@ -62,19 +62,19 @@ |
2377 | */ |
2378 | ScoreboardSlot* findOurScoreboardSlot(drizzled::Session *session); |
2379 | |
2380 | - uint32_t getBucketNumber(drizzled::Session*) const; |
2381 | + uint32_t getBucketNumber(drizzled::Session *session); |
2382 | |
2383 | - uint32_t getNumberBuckets() const |
2384 | + uint32_t getNumberBuckets() |
2385 | { |
2386 | return number_buckets; |
2387 | } |
2388 | |
2389 | - uint32_t getNumberPerBucket() const |
2390 | + uint32_t getNumberPerBucket() |
2391 | { |
2392 | return number_per_bucket; |
2393 | } |
2394 | |
2395 | - uint64_t getScoreboardSizeBytes() const |
2396 | + uint64_t getScoreboardSizeBytes() |
2397 | { |
2398 | return scoreboard_size_bytes; |
2399 | } |
2400 | @@ -94,8 +94,8 @@ |
2401 | uint32_t number_per_bucket; |
2402 | uint32_t number_buckets; |
2403 | uint64_t scoreboard_size_bytes; |
2404 | - std::vector<std::vector<ScoreboardSlot*>*> vector_of_scoreboard_vectors; |
2405 | - std::vector<boost::shared_mutex*> vector_of_scoreboard_locks; |
2406 | + std::vector<std::vector<ScoreboardSlot* >* > vector_of_scoreboard_vectors; |
2407 | + std::vector<boost::shared_mutex* > vector_of_scoreboard_locks; |
2408 | |
2409 | ScoreboardSlot* claimOpenScoreboardSlot(drizzled::Session *session); |
2410 | }; |
2411 | |
2412 | === modified file 'plugin/mysql_protocol/mysql_protocol.cc' |
2413 | --- plugin/mysql_protocol/mysql_protocol.cc 2011-06-13 14:33:05 +0000 |
2414 | +++ plugin/mysql_protocol/mysql_protocol.cc 2011-08-07 13:22:33 +0000 |
2415 | @@ -516,6 +516,10 @@ |
2416 | pos[6]= DRIZZLE_COLUMN_TYPE_VARCHAR; |
2417 | break; |
2418 | |
2419 | + case DRIZZLE_TYPE_IPV6: |
2420 | + pos[6]= DRIZZLE_COLUMN_TYPE_VARCHAR; |
2421 | + break; |
2422 | + |
2423 | case DRIZZLE_TYPE_BOOLEAN: |
2424 | pos[6]= DRIZZLE_COLUMN_TYPE_TINY; |
2425 | break; |
2426 | |
2427 | === modified file 'tests/include.am' |
2428 | --- tests/include.am 2011-07-28 07:57:26 +0000 |
2429 | +++ tests/include.am 2011-08-07 13:22:33 +0000 |
2430 | @@ -23,7 +23,7 @@ |
2431 | GENSCRIPTS = tests/dtr tests/mtr tests/test-run tests/dbqp |
2432 | PRESCRIPTS = tests/test-run.pl tests/stress-test.pl |
2433 | PLUGIN_TESTS = $(pandora_plugin_test_list) |
2434 | -NORMAL_TESTS = main,bool_type,cast,ddl_transactions,execute,flush_tables,identifiers,jp,mysql_compatibility,regression,tamil,time_type,unsigned_integer_type,uuid_type,microtime_type,$(PLUGIN_TESTS) |
2435 | +NORMAL_TESTS = main,bool_type,cast,ddl_transactions,execute,flush_tables,identifiers,jp,mysql_compatibility,regression,tamil,time_type,unsigned_integer_type,ipv6_type,uuid_type,microtime_type,$(PLUGIN_TESTS) |
2436 | ALL_TESTS = main,big,jp,tamil,regression,microtime_type,$(PLUGIN_TESTS) |
2437 | noinst_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) |
2438 | CLEANFILES += $(GENSCRIPTS) tests/mtr |
2439 | |
2440 | === added directory 'tests/suite/ipv6_type' |
2441 | === added directory 'tests/suite/ipv6_type/r' |
2442 | === added file 'tests/suite/ipv6_type/r/alter_add_ipv6.result' |
2443 | --- tests/suite/ipv6_type/r/alter_add_ipv6.result 1970-01-01 00:00:00 +0000 |
2444 | +++ tests/suite/ipv6_type/r/alter_add_ipv6.result 2011-08-07 13:22:33 +0000 |
2445 | @@ -0,0 +1,44 @@ |
2446 | +CREATE TABLE t1 (A INT); |
2447 | +SHOW CREATE TABLE t1; |
2448 | +Table Create Table |
2449 | +t1 CREATE TABLE `t1` ( |
2450 | + `A` INT DEFAULT NULL |
2451 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2452 | +ALTER TABLE t1 ADD COLUMN b IPV6 NOT NULL; |
2453 | +SHOW CREATE TABLE t1; |
2454 | +Table Create Table |
2455 | +t1 CREATE TABLE `t1` ( |
2456 | + `A` INT DEFAULT NULL, |
2457 | + `b` IPV6 NOT NULL |
2458 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2459 | +DROP TABLE t1; |
2460 | +CREATE TABLE t1 (A INT); |
2461 | +SHOW CREATE TABLE t1; |
2462 | +Table Create Table |
2463 | +t1 CREATE TABLE `t1` ( |
2464 | + `A` INT DEFAULT NULL |
2465 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2466 | +INSERT INTO t1 VALUES (1), (2), (3); |
2467 | +SELECT COUNT(*) = 3 FROM t1; |
2468 | +COUNT(*) = 3 |
2469 | +1 |
2470 | +ALTER TABLE t1 ADD COLUMN b IPV6 NOT NULL; |
2471 | +ERROR HY000: Either a DEFAULt value or NULL NULL description is required for a new column if table is not empty |
2472 | +SHOW CREATE TABLE t1; |
2473 | +Table Create Table |
2474 | +t1 CREATE TABLE `t1` ( |
2475 | + `A` INT DEFAULT NULL |
2476 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2477 | +ALTER TABLE t1 ADD COLUMN b IPV6 DEFAULT NULL; |
2478 | +SELECT A,B FROM t1; |
2479 | +A B |
2480 | +1 NULL |
2481 | +2 NULL |
2482 | +3 NULL |
2483 | +SHOW CREATE TABLE t1; |
2484 | +Table Create Table |
2485 | +t1 CREATE TABLE `t1` ( |
2486 | + `A` INT DEFAULT NULL, |
2487 | + `b` IPV6 DEFAULT NULL |
2488 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2489 | +DROP TABLE t1; |
2490 | |
2491 | === added file 'tests/suite/ipv6_type/r/bad_conversions.result' |
2492 | --- tests/suite/ipv6_type/r/bad_conversions.result 1970-01-01 00:00:00 +0000 |
2493 | +++ tests/suite/ipv6_type/r/bad_conversions.result 2011-08-07 13:22:33 +0000 |
2494 | @@ -0,0 +1,24 @@ |
2495 | +CREATE TABLE t1 (a IPV6, PRIMARY KEY(a)); |
2496 | +show create table t1; |
2497 | +Table Create Table |
2498 | +t1 CREATE TABLE `t1` ( |
2499 | + `a` IPV6 NOT NULL, |
2500 | + PRIMARY KEY (`a`) USING BTREE |
2501 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2502 | +INSERT INTO t1 VALUES ("10FB::C:ABC:1F0C:44DA"); |
2503 | +SELECT a FROM t1; |
2504 | +a |
2505 | +10fb:0000:0000:0000:000c:0abc:1f0c:44da |
2506 | +CREATE TABLE t2 (a REAL); |
2507 | +INSERT INTO t2 SELECT a FROM t1 LIMIT 1; |
2508 | +ERROR 01000: Data truncated for column 'a' at row 1 |
2509 | +SELECT a FROM t2; |
2510 | +a |
2511 | +CREATE TABLE t3 (a REAL); |
2512 | +INSERT INTO t3 SELECT a FROM t1 LIMIT 1; |
2513 | +ERROR 01000: Data truncated for column 'a' at row 1 |
2514 | +SELECT a FROM t3; |
2515 | +a |
2516 | +DROP TABLE t3; |
2517 | +DROP TABLE t2; |
2518 | +DROP TABLE t1; |
2519 | |
2520 | === added file 'tests/suite/ipv6_type/r/count.result' |
2521 | --- tests/suite/ipv6_type/r/count.result 1970-01-01 00:00:00 +0000 |
2522 | +++ tests/suite/ipv6_type/r/count.result 2011-08-07 13:22:33 +0000 |
2523 | @@ -0,0 +1,19 @@ |
2524 | +CREATE TABLE t1 (a IPV6); |
2525 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2526 | +INSERT INTO t1 VALUES ("::1"); |
2527 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2528 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2529 | +SELECT a FROM t1; |
2530 | +a |
2531 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2532 | +0000:0000:0000:0000:0000:0000:0000:0001 |
2533 | +000:000:000:000:000:000:192.168.100.010 |
2534 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2535 | +SELECT count(a) FROM t1; |
2536 | +count(a) |
2537 | +4 |
2538 | +TRUNCATE t1; |
2539 | +SELECT count(a) FROM t1; |
2540 | +count(a) |
2541 | +0 |
2542 | +DROP TABLE t1; |
2543 | |
2544 | === added file 'tests/suite/ipv6_type/r/create.result' |
2545 | --- tests/suite/ipv6_type/r/create.result 1970-01-01 00:00:00 +0000 |
2546 | +++ tests/suite/ipv6_type/r/create.result 2011-08-07 13:22:33 +0000 |
2547 | @@ -0,0 +1,7 @@ |
2548 | +CREATE TABLE t1 (a IPV6); |
2549 | +show create table t1; |
2550 | +Table Create Table |
2551 | +t1 CREATE TABLE `t1` ( |
2552 | + `a` IPV6 DEFAULT NULL |
2553 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2554 | +DROP TABLE t1; |
2555 | |
2556 | === added file 'tests/suite/ipv6_type/r/delete.result' |
2557 | --- tests/suite/ipv6_type/r/delete.result 1970-01-01 00:00:00 +0000 |
2558 | +++ tests/suite/ipv6_type/r/delete.result 2011-08-07 13:22:33 +0000 |
2559 | @@ -0,0 +1,23 @@ |
2560 | +CREATE TABLE t1 (a IPV6); |
2561 | +show create table t1; |
2562 | +Table Create Table |
2563 | +t1 CREATE TABLE `t1` ( |
2564 | + `a` IPV6 DEFAULT NULL |
2565 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2566 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2567 | +INSERT INTO t1 VALUES ("::1"); |
2568 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2569 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2570 | +SELECT a FROM t1; |
2571 | +a |
2572 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2573 | +0000:0000:0000:0000:0000:0000:0000:0001 |
2574 | +000:000:000:000:000:000:192.168.100.010 |
2575 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2576 | +DELETE FROM t1 WHERE a = "0000:0000:0000:0000:0000:0000:0000:0001"; |
2577 | +SELECT a FROM t1; |
2578 | +a |
2579 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2580 | +000:000:000:000:000:000:192.168.100.010 |
2581 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2582 | +DROP TABLE t1; |
2583 | |
2584 | === added file 'tests/suite/ipv6_type/r/mixed.result' |
2585 | --- tests/suite/ipv6_type/r/mixed.result 1970-01-01 00:00:00 +0000 |
2586 | +++ tests/suite/ipv6_type/r/mixed.result 2011-08-07 13:22:33 +0000 |
2587 | @@ -0,0 +1,17 @@ |
2588 | +CREATE TABLE t1 (a IPV6); |
2589 | +CREATE TABLE t2 (a VARCHAR(39)); |
2590 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2591 | +SELECT a FROM t1; |
2592 | +a |
2593 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2594 | +INSERT INTO t2 SELECT a FROM t1; |
2595 | +SELECT a FROM t2; |
2596 | +a |
2597 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2598 | +TRUNCATE t1; |
2599 | +INSERT INTO t1 SELECT a FROM t2; |
2600 | +SELECT a FROM t2; |
2601 | +a |
2602 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2603 | +DROP TABLE t2; |
2604 | +DROP TABLE t1; |
2605 | |
2606 | === added file 'tests/suite/ipv6_type/r/order_by.result' |
2607 | --- tests/suite/ipv6_type/r/order_by.result 1970-01-01 00:00:00 +0000 |
2608 | +++ tests/suite/ipv6_type/r/order_by.result 2011-08-07 13:22:33 +0000 |
2609 | @@ -0,0 +1,23 @@ |
2610 | +CREATE TABLE t1 (a IPV6); |
2611 | +show create table t1; |
2612 | +Table Create Table |
2613 | +t1 CREATE TABLE `t1` ( |
2614 | + `a` IPV6 DEFAULT NULL |
2615 | +) ENGINE=InnoDB COLLATE = utf8_general_ci |
2616 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2617 | +INSERT INTO t1 VALUES ("::1"); |
2618 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2619 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2620 | +SELECT a FROM t1; |
2621 | +a |
2622 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2623 | +0000:0000:0000:0000:0000:0000:0000:0001 |
2624 | +000:000:000:000:000:000:192.168.100.010 |
2625 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2626 | +SELECT a FROM t1 ORDER BY a; |
2627 | +a |
2628 | +0000:0000:0000:0000:0000:0000:0000:0001 |
2629 | +000:000:000:000:000:000:192.168.100.010 |
2630 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2631 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2632 | +DROP TABLE t1; |
2633 | |
2634 | === added file 'tests/suite/ipv6_type/r/primary_key.result' |
2635 | --- tests/suite/ipv6_type/r/primary_key.result 1970-01-01 00:00:00 +0000 |
2636 | +++ tests/suite/ipv6_type/r/primary_key.result 2011-08-07 13:22:33 +0000 |
2637 | @@ -0,0 +1,14 @@ |
2638 | +CREATE TABLE t1 (a IPV6, PRIMARY KEY(a)); |
2639 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2640 | +INSERT INTO t1 VALUES ("::1"); |
2641 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2642 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2643 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2644 | +ERROR 23000: Duplicate entry '2001:0db8:85a3:0000:0000:8a2e:0370:7334' for key 'PRIMARY' |
2645 | +SELECT a FROM t1 ORDER BY a; |
2646 | +a |
2647 | +0000:0000:0000:0000:0000:0000:0000:0001 |
2648 | +000:000:000:000:000:000:192.168.100.010 |
2649 | +2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
2650 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2651 | +DROP TABLE t1; |
2652 | |
2653 | === added file 'tests/suite/ipv6_type/r/select_like_no_key.result' |
2654 | --- tests/suite/ipv6_type/r/select_like_no_key.result 1970-01-01 00:00:00 +0000 |
2655 | +++ tests/suite/ipv6_type/r/select_like_no_key.result 2011-08-07 13:22:33 +0000 |
2656 | @@ -0,0 +1,18 @@ |
2657 | +CREATE TABLE t1 (a IPV6); |
2658 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2659 | +INSERT INTO t1 VALUES ("FD01::1F"); |
2660 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2661 | +INSERT INTO t1 VALUES ("::1"); |
2662 | +SELECT a FROM t1; |
2663 | +a |
2664 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2665 | +fd01:0000:0000:0000:0000:0000:0000:001f |
2666 | +000:000:000:000:000:000:192.168.100.010 |
2667 | +0000:0000:0000:0000:0000:0000:0000:0001 |
2668 | +SELECT a FROM t1 WHERE a = "0fe8:0000:0000:0000:0000:b3ff:fe1a:8329"; |
2669 | +a |
2670 | +0fe8:0000:0000:0000:0000:b3ff:fe1a:8329 |
2671 | +SELECT a FROM t1 WHERE a LIKE "000:000:000:000:000:000:192.168.100.010"; |
2672 | +a |
2673 | +000:000:000:000:000:000:192.168.100.010 |
2674 | +DROP TABLE t1; |
2675 | |
2676 | === added directory 'tests/suite/ipv6_type/t' |
2677 | === added file 'tests/suite/ipv6_type/t/alter_add_ipv6.test' |
2678 | --- tests/suite/ipv6_type/t/alter_add_ipv6.test 1970-01-01 00:00:00 +0000 |
2679 | +++ tests/suite/ipv6_type/t/alter_add_ipv6.test 2011-08-07 13:22:33 +0000 |
2680 | @@ -0,0 +1,17 @@ |
2681 | +CREATE TABLE t1 (A INT); |
2682 | +SHOW CREATE TABLE t1; |
2683 | +ALTER TABLE t1 ADD COLUMN b IPV6 NOT NULL; |
2684 | +SHOW CREATE TABLE t1; |
2685 | +DROP TABLE t1; |
2686 | + |
2687 | +CREATE TABLE t1 (A INT); |
2688 | +SHOW CREATE TABLE t1; |
2689 | +INSERT INTO t1 VALUES (1), (2), (3); |
2690 | +SELECT COUNT(*) = 3 FROM t1; |
2691 | +--error ER_INVALID_ALTER_TABLE_FOR_NOT_NULL |
2692 | +ALTER TABLE t1 ADD COLUMN b IPV6 NOT NULL; |
2693 | +SHOW CREATE TABLE t1; |
2694 | +ALTER TABLE t1 ADD COLUMN b IPV6 DEFAULT NULL; |
2695 | +SELECT A,B FROM t1; |
2696 | +SHOW CREATE TABLE t1; |
2697 | +DROP TABLE t1; |
2698 | |
2699 | === added file 'tests/suite/ipv6_type/t/bad_conversions.test' |
2700 | --- tests/suite/ipv6_type/t/bad_conversions.test 1970-01-01 00:00:00 +0000 |
2701 | +++ tests/suite/ipv6_type/t/bad_conversions.test 2011-08-07 13:22:33 +0000 |
2702 | @@ -0,0 +1,15 @@ |
2703 | +CREATE TABLE t1 (a IPV6, PRIMARY KEY(a)); |
2704 | +show create table t1; |
2705 | +INSERT INTO t1 VALUES ("10FB::C:ABC:1F0C:44DA"); |
2706 | +SELECT a FROM t1; |
2707 | +CREATE TABLE t2 (a REAL); |
2708 | +--error ER_WARN_DATA_TRUNCATED |
2709 | +INSERT INTO t2 SELECT a FROM t1 LIMIT 1; |
2710 | +SELECT a FROM t2; |
2711 | +CREATE TABLE t3 (a REAL); |
2712 | +--error ER_WARN_DATA_TRUNCATED |
2713 | +INSERT INTO t3 SELECT a FROM t1 LIMIT 1; |
2714 | +SELECT a FROM t3; |
2715 | +DROP TABLE t3; |
2716 | +DROP TABLE t2; |
2717 | +DROP TABLE t1; |
2718 | |
2719 | === added file 'tests/suite/ipv6_type/t/count.test' |
2720 | --- tests/suite/ipv6_type/t/count.test 1970-01-01 00:00:00 +0000 |
2721 | +++ tests/suite/ipv6_type/t/count.test 2011-08-07 13:22:33 +0000 |
2722 | @@ -0,0 +1,10 @@ |
2723 | +CREATE TABLE t1 (a IPV6); |
2724 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2725 | +INSERT INTO t1 VALUES ("::1"); |
2726 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2727 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2728 | +SELECT a FROM t1; |
2729 | +SELECT count(a) FROM t1; |
2730 | +TRUNCATE t1; |
2731 | +SELECT count(a) FROM t1; |
2732 | +DROP TABLE t1; |
2733 | |
2734 | === added file 'tests/suite/ipv6_type/t/create.test' |
2735 | --- tests/suite/ipv6_type/t/create.test 1970-01-01 00:00:00 +0000 |
2736 | +++ tests/suite/ipv6_type/t/create.test 2011-08-07 13:22:33 +0000 |
2737 | @@ -0,0 +1,3 @@ |
2738 | +CREATE TABLE t1 (a IPV6); |
2739 | +show create table t1; |
2740 | +DROP TABLE t1; |
2741 | |
2742 | === added file 'tests/suite/ipv6_type/t/delete.test' |
2743 | --- tests/suite/ipv6_type/t/delete.test 1970-01-01 00:00:00 +0000 |
2744 | +++ tests/suite/ipv6_type/t/delete.test 2011-08-07 13:22:33 +0000 |
2745 | @@ -0,0 +1,10 @@ |
2746 | +CREATE TABLE t1 (a IPV6); |
2747 | +show create table t1; |
2748 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2749 | +INSERT INTO t1 VALUES ("::1"); |
2750 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2751 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2752 | +SELECT a FROM t1; |
2753 | +DELETE FROM t1 WHERE a = "0000:0000:0000:0000:0000:0000:0000:0001"; |
2754 | +SELECT a FROM t1; |
2755 | +DROP TABLE t1; |
2756 | |
2757 | === added file 'tests/suite/ipv6_type/t/mixed.test' |
2758 | --- tests/suite/ipv6_type/t/mixed.test 1970-01-01 00:00:00 +0000 |
2759 | +++ tests/suite/ipv6_type/t/mixed.test 2011-08-07 13:22:33 +0000 |
2760 | @@ -0,0 +1,11 @@ |
2761 | +CREATE TABLE t1 (a IPV6); |
2762 | +CREATE TABLE t2 (a VARCHAR(39)); |
2763 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2764 | +SELECT a FROM t1; |
2765 | +INSERT INTO t2 SELECT a FROM t1; |
2766 | +SELECT a FROM t2; |
2767 | +TRUNCATE t1; |
2768 | +INSERT INTO t1 SELECT a FROM t2; |
2769 | +SELECT a FROM t2; |
2770 | +DROP TABLE t2; |
2771 | +DROP TABLE t1; |
2772 | |
2773 | === added file 'tests/suite/ipv6_type/t/order_by.test' |
2774 | --- tests/suite/ipv6_type/t/order_by.test 1970-01-01 00:00:00 +0000 |
2775 | +++ tests/suite/ipv6_type/t/order_by.test 2011-08-07 13:22:33 +0000 |
2776 | @@ -0,0 +1,9 @@ |
2777 | +CREATE TABLE t1 (a IPV6); |
2778 | +show create table t1; |
2779 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2780 | +INSERT INTO t1 VALUES ("::1"); |
2781 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2782 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2783 | +SELECT a FROM t1; |
2784 | +SELECT a FROM t1 ORDER BY a; |
2785 | +DROP TABLE t1; |
2786 | |
2787 | === added file 'tests/suite/ipv6_type/t/primary_key.test' |
2788 | --- tests/suite/ipv6_type/t/primary_key.test 1970-01-01 00:00:00 +0000 |
2789 | +++ tests/suite/ipv6_type/t/primary_key.test 2011-08-07 13:22:33 +0000 |
2790 | @@ -0,0 +1,9 @@ |
2791 | +CREATE TABLE t1 (a IPV6, PRIMARY KEY(a)); |
2792 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2793 | +INSERT INTO t1 VALUES ("::1"); |
2794 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2795 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2796 | +--error ER_DUP_ENTRY |
2797 | +INSERT INTO t1 VALUES ("2001:db8:85a3::8a2e:370:7334"); |
2798 | +SELECT a FROM t1 ORDER BY a; |
2799 | +DROP TABLE t1; |
2800 | |
2801 | === added file 'tests/suite/ipv6_type/t/select_like_no_key.test' |
2802 | --- tests/suite/ipv6_type/t/select_like_no_key.test 1970-01-01 00:00:00 +0000 |
2803 | +++ tests/suite/ipv6_type/t/select_like_no_key.test 2011-08-07 13:22:33 +0000 |
2804 | @@ -0,0 +1,9 @@ |
2805 | +CREATE TABLE t1 (a IPV6); |
2806 | +INSERT INTO t1 VALUES ("fe8::b3ff:fe1a:8329"); |
2807 | +INSERT INTO t1 VALUES ("FD01::1F"); |
2808 | +INSERT INTO t1 VALUES ("::192.168.100.10"); |
2809 | +INSERT INTO t1 VALUES ("::1"); |
2810 | +SELECT a FROM t1; |
2811 | +SELECT a FROM t1 WHERE a = "0fe8:0000:0000:0000:0000:b3ff:fe1a:8329"; |
2812 | +SELECT a FROM t1 WHERE a LIKE "000:000:000:000:000:000:192.168.100.010"; |
2813 | +DROP TABLE t1; |
I think there's a problem with the diff. See for example drizzled/ module/ registry. cc
Seems you didn't pick up some updates in trunk.