26 #include <uuid/uuid.h>
28 #include <drizzled/field/uuid.h>
30 #include <drizzled/error.h>
31 #include <drizzled/internal/my_sys.h>
32 #include <drizzled/session.h>
33 #include <drizzled/table.h>
40 Uuid::Uuid(
unsigned char *ptr_arg,
42 unsigned char *null_ptr_arg,
43 unsigned char null_bit_arg,
44 const char *field_name_arg) :
45 Field(ptr_arg, len_arg,
54 int Uuid::cmp(
const unsigned char *a,
const unsigned char *b)
56 return memcmp(a, b,
sizeof(uuid_t));
59 int Uuid::store(
const char *from, uint32_t length,
const charset_info_st *
const )
61 ASSERT_COLUMN_MARKED_FOR_WRITE;
70 if (length != type::Uuid::DISPLAY_LENGTH)
72 my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
78 my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
87 int Uuid::store(int64_t ,
bool )
89 ASSERT_COLUMN_MARKED_FOR_WRITE;
90 my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
96 ASSERT_COLUMN_MARKED_FOR_WRITE;
97 my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
101 double Uuid::val_real()
const
103 ASSERT_COLUMN_MARKED_FOR_READ;
104 my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
108 int64_t Uuid::val_int()
const
110 ASSERT_COLUMN_MARKED_FOR_READ;
111 my_error(ER_INVALID_UUID_VALUE, MYF(ME_FATALERROR));
116 void Uuid::generate()
119 uuid_generate_time(uu);
120 memcpy(ptr, uu,
sizeof(uuid_t));
124 void Uuid::set(
const unsigned char *arg)
126 memcpy(ptr, arg,
sizeof(uuid_t));
131 String *Uuid::val_str(String *val_buffer, String *)
const
133 const charset_info_st *
const cs= &my_charset_bin;
134 uint32_t mlength= (type::Uuid::DISPLAY_BUFFER_LENGTH) * cs->mbmaxlen;
137 val_buffer->alloc(mlength);
138 char *buffer=(
char*) val_buffer->ptr();
140 ASSERT_COLUMN_MARKED_FOR_READ;
145 val_buffer->length(type::Uuid::DISPLAY_LENGTH);
150 void Uuid::sort_string(
unsigned char *to, uint32_t length_arg)
152 assert(length_arg == type::Uuid::LENGTH);
153 memcpy(to, ptr, length_arg);
156 bool Uuid::get_date(type::Time <ime, uint32_t )
const
164 struct timeval ret_tv;
166 memset(&ret_tv, 0,
sizeof(
struct timeval));
179 bool Uuid::get_time(type::Time <ime)
const
181 return get_date(ltime, 0);
TODO: Rename this file - func.h is stupid.