| 2369 | } |
| 2370 | |
| 2371 | void Item_hex_string::hex_string_init(const char *str, uint str_length) |
| 2372 | { |
| 2373 | max_length=(str_length+1)/2; |
| 2374 | char *ptr=(char*) sql_alloc(max_length+1); |
| 2375 | if (!ptr) |
| 2376 | { |
| 2377 | str_value.set("", 0, &my_charset_bin); |
| 2378 | return; |
| 2379 | } |
| 2380 | str_value.set(ptr,max_length,&my_charset_bin); |
| 2381 | char *end=ptr+max_length; |
| 2382 | if (max_length*2 != str_length) |
| 2383 | *ptr++=char_val(*str++); // Not even, assume 0 prefix |
| 2384 | while (ptr != end) |
| 2385 | { |
| 2386 | *ptr++= (char) (char_val(str[0])*16+char_val(str[1])); |
| 2387 | str+=2; |
| 2388 | } |
| 2389 | *ptr=0; // Keep purify happy |
| 2390 | collation.set(&my_charset_bin, DERIVATION_COERCIBLE); |
| 2391 | fixed= 1; |
| 2392 | unsigned_flag= 1; |
| 2393 | } |
| 2394 | |
| 2395 | longlong Item_hex_string::val_int() |
| 2396 | { |